Creature Control for Unity v0.1
Loading...
Searching...
No Matches
Creatures.CreatureController Class Reference

Description

Component to control the locomotion of a Creature.

Using this component the creature can walk around with 3 degrees of freedom:

  • forward
  • sideward
  • rotation The motions can be controller using input actions (moveAction, rotateAction) or using code by calling one of the Move functions

Unity Properties

  • CreatureController.movedBy
  • CreatureController.moveAction
  • CreatureController.rotateAction
  • CreatureController.speed

Public Types

enum  Mode { Animator , Transform , External }
 Mode for controlling the creature transform. More...

Public Member Functions

void Move (Vector2 linear, float angular)
 Move the creature.
void MoveByAnimator (Vector2 linear, float angular)
 Move the creature using the animator directly.
void MoveByTransform (Vector2 linear, float angular)
 Move the creature using the Rigidbody or Transform.
void MoveExternal ()
 Move the creature by moving the Transform directly.

Public Attributes

Mode movedBy
 Set the mode for controlling animations and movements.
InputActionReference moveAction
 The input action for linear motion.
InputActionReference rotateAction
 The input action for rotation motion.
float speed = 1
 The maximum linear locomotion speed in m/s.

Protected Member Functions

virtual void Awake ()
 Unity calls Awake when loading an instance of a script component.
virtual void OnEnable ()
 Called by Unity when a component of an active GameObject is first enabled.
virtual void OnDisable ()
 Called by Unity when a component itself is disabled or its parent GameObject is deactivated.
virtual void Update ()
 Update is called by Unity every frame, if the MonoBehaviour is enabled.

Protected Attributes

Creature creature
 The creature to control.
Rigidbody rigidbody
 The (optional) rigidbody of the creature.
Animator animator
 The (optional) animator for the animations.

Member Enumeration Documentation

◆ Mode

Mode for controlling the creature transform.

Enumerator
Animator 

Animations move the transform.

Transform 

Transform movements drive the animations.

External 

The movements are done externally, animations will follow.

Member Function Documentation

◆ Move()

void Creatures.CreatureController.Move ( Vector2 linear,
float angular )

Move the creature.

Parameters
linearThe desired 2D linear velocity
angularThe desired angular velocity around the vertical axis

If the creature has a non-Kinematic Rigidbody the Mode.External is always chosen

◆ MoveByAnimator()

void Creatures.CreatureController.MoveByAnimator ( Vector2 linear,
float angular )

Move the creature using the animator directly.

Parameters
linearThe desired 2D linear velocity
angularThe desired angular velocity around the vertical axis

This bypasses the CreatureController.movedBy parameter and will also work when a non-kinematic Rigidbody is present

◆ MoveByTransform()

void Creatures.CreatureController.MoveByTransform ( Vector2 linear,
float angular )

Move the creature using the Rigidbody or Transform.

Parameters
linearThe desired 2D linear velocity
angularThe desired angular velocity around the vertical axis

If a Rigidbody is present, Rigidbody::Move is used. If not, Transform::Translate and Transform::Rotate are used

When using a Rigidbody, call this function from UnityEngine::FixedUpdate.


The documentation for this class was generated from the following file: