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
Inheritance diagram for Creatures.CreatureController:
Creatures.Insects.InsectController

Public Types

enum  Mode { Transform }
 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.
virtual void MoveTransform (Vector2 linear, float angular)
 Move the creature using the Rigidbody or Transform.
virtual void MoveKinematicRigidbody (Vector2 linear, float angular)
 Move the creature for a kinematic Rigidbody.
virtual void MoveDynamicRigidbody (Vector2 linear, float angular)
 Move the creature for a non-kinematic Rigidbody.

Public Attributes

Mode movedBy = Mode.Transform
 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 maxLinearSpeed = 1
 The maximum linear locomotion speed in meters/second.
float maxAngularSpeed = 90
 The maximum angular locomotion speed in degrees/second.

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.
virtual void FixedUpdate ()
 Update called at regular, fixed intervals as part of Unity's physics update loop.

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
Transform 

Animations move the transform (currently unsupported).

Transform movements drive the animations

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

◆ 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

◆ MoveTransform()

virtual void Creatures.CreatureController.MoveTransform ( Vector2 linear,
float angular )
virtual

Move the creature using the Rigidbody or Transform.

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

This function needs to be called from the Update() loop

Reimplemented in Creatures.Insects.InsectController.

◆ MoveKinematicRigidbody()

virtual void Creatures.CreatureController.MoveKinematicRigidbody ( Vector2 linear,
float angular )
virtual

Move the creature for a kinematic Rigidbody.

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

This function needs to be called in the FixedUpdate() loop

Reimplemented in Creatures.Insects.InsectController.

◆ MoveDynamicRigidbody()

virtual void Creatures.CreatureController.MoveDynamicRigidbody ( Vector2 linear,
float angular )
virtual

Move the creature for a non-kinematic Rigidbody.

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

This function needs to be called in the FixedUpdate() loop


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