All Classes Namespaces Functions Variables Enumerations Enumerator Properties
plyGame.CharacterControllerBase Class Reference

The base class for all plyGame related character controllers. More...

Inherits plyGame.Targetable, and plyGame.IPersistable.

Inherited by plyGame.NPCController, and plyGame.PlayerBaseController.

Public Types

enum  ValidInteractTargets { FriendlyActor = (1 << 0), NeutralActor = (1 << 1), HostileActor = (1 << 2), RPGObject = (1 << 3) }
 
- Public Types inherited from plyGame.Targetable
enum  Type { Type.Character = 1, Type.Object = 2, Type.Item = 4, Type.Unknown = 1024 }
 The targetable types More...
 

Public Member Functions

void Save (string key)
 
void Load (string key)
 
void DeleteSaveData (string key)
 
void DisablePersistence ()
 
void SelectTarget (GameObject go)
 Called when a target is selected. et the selected target. If null or passed object is not a Targetable, then the selected target will be cleared. You should call base.SelectTarget() if you override this. More...
 
virtual void SelectTarget (Targetable t)
 Called when a target is selected. If null then the selected target will be cleared. You should call base.SelectTarget() if you override this. More...
 
virtual void ClearTarget ()
 Called when the target is cleared. You should call base.ClearTarget() if you override this. More...
 
virtual void SetTargetInteract (GameObject go)
 The gameObject as target interact. The character will try to move to it and face it before the Interact related events are triggered. More...
 
virtual void SetTargetInteract (Targetable t)
 The character will try to move to it and face it before the Interact related events are triggered. More...
 
virtual void StopInteract ()
 Trigger event on currently active interact More...
 
override Type TargetableType ()
 You will not need to override this in a base class as it already returns Type.Character. More...
 
override object DataObject ()
 You will not need to override this in a base class as it already returns actor (as data object). More...
 
virtual bool MovementControlAllowed ()
 Return true if the character may accept input to generate movement More...
 
virtual bool IsPlayer ()
 Derived class must override this to tell plyGame if this controller (Character) is a player character controller or non-player character (NPC). More...
 
virtual void EnableControl (bool en)
 Enable or Disable Input (or AI in case of NPCs). Call base.EnableControl() if you override this. More...
 
virtual void OnDeath ()
 Called when the character is killed. Call base.Death() if you override this. More...
 
virtual void SetMoveSpeed (float speed)
 Set the movement speed of the character More...
 
virtual void SetTurnSpeed (float speed)
 Set the turn speed of the character More...
 
virtual float MoveSpeed ()
 Return the current move speed being used. This defaults to returning moveSpeed but some controllers might override this if they have other movement speed types, for example running during a chase. More...
 
virtual float TurnSpeed ()
 Return the current turn speed being used. This defaults to returning turnSpeed but some controllers might override this if they have other movement speed types, for example running during a chase. More...
 
virtual bool Grounded ()
 Is the character touching the floor/ ground? More...
 
virtual Vector3 Velocity ()
 Character's current velocity More...
 
virtual Vector3 Movement ()
 The calculated move vector. Needed by animation controllers that controls root motion, like the basic mecanim controller. More...
 
virtual bool RequestFaceDirection (Vector3 direction, float delayAfter)
 Turn the character to face in direction. Return false if this character controller do not accept requests to turn. Actor uses this to ask the character to look in direction it needs to perform a skill. The delayAfter determine how long the character will face the target direction, after reaching it and before returning to viewing in direction it is moving (if moving). More...
 
virtual bool RequestLookAt (Vector3 position, float delayAfter)
 Turn the character to face the target location (position). Return false if this character controller do not accept requests to turn. Actor uses this to ask the character to look in a direction to perform skill. The delayAfter determine how long the character will face the target direction, after reaching it and before returning to viewing in direction is is moving (if moving). More...
 
virtual bool RequestMoveTo (Vector3 position, bool useFasterMovement)
 Move the character to position. Return false if this character controller do not accept requests to move. Actor uses this to ask the character to move, for example when it needs the character to move closer to selected target or to perform a skill. More...
 
virtual void Stop ()
 Ask character to stop moving and/ or turning More...
 
virtual void StopAll ()
 Ask character to stop. Removing queued targets and stop moving. More...
 
- Public Member Functions inherited from plyGame.Targetable
virtual bool MustFaceToInteract ()
 Override to to specify when facing the object is not needed to interact with it. Default is True. More...
 

Public Attributes

bool persistenceOn = false
 
bool persistSpeed = true
 
float moveSpeed = 5.0f
 How fast the character should be moving when moving (or max speed it can reach)
 
float turnSpeed = 10.0f
 How fast the character can turn when turning (or max turn speed)
 
float maxInteractDistance = 2f
 max distance this character can be from something to interact with it
 
ValidInteractTargets validInteractTarget = (ValidInteractTargets.FriendlyActor | ValidInteractTargets.NeutralActor | ValidInteractTargets.RPGObject)
 
ResultCallback onJump
 Assign to this a delegate to respond to the character jumping. LegacyAnimControl for example hooks into this so it knows when to play the jump clip.
 
GeneralCallback onDeath
 Assign to this a delegate to respond to the character dying. LegacyAnimControl for example hooks into this so it knows when to play the death clip.
 
- Public Attributes inherited from plyGame.Targetable
GeneralCallback onDestroy
 Assign to this a delegate to respond to this object being destroyed.
 

Protected Member Functions

void Awake ()
 
void Start ()
 
void LateUpdate ()
 
- Protected Member Functions inherited from plyGame.Targetable
void OnDestroy ()
 

Properties

Targetable selectedTarget [get, set]
 This character's currently selected Targetable object. For player controllers this would be what the player clicked on (characters, items and objects) last and for NPCs this would be what the AI selected (only other characters) More...
 
Targetable queuedInteract [get, set]
 The object queued to be interacted with once character is in range and facing it. More...
 
bool Interacting [get]
 True while the character is "interacting" with something. StopInteract() must be called to stop it. More...
 
Actor actor [get, set]
 The Actor component of the character More...
 
Transform _tr [get, set]
 The Transform component of the character More...
 
bool hint_DoNotMove [get, set]
 If set then the character should not move. Normally set by actor when a skill being used do not allow movement. More...
 
bool controlEnabled [get, set]
 Is control of the character enabled? Player characters should not accept input and an NPC's I should be off when this is false. More...
 

Detailed Description

The base class for all plyGame related character controllers.

Member Function Documentation

virtual void plyGame.CharacterControllerBase.ClearTarget ( )
virtual

Called when the target is cleared. You should call base.ClearTarget() if you override this.

override object plyGame.CharacterControllerBase.DataObject ( )
virtual

You will not need to override this in a base class as it already returns actor (as data object).

Reimplemented from plyGame.Targetable.

virtual void plyGame.CharacterControllerBase.EnableControl ( bool  en)
virtual

Enable or Disable Input (or AI in case of NPCs). Call base.EnableControl() if you override this.

virtual bool plyGame.CharacterControllerBase.Grounded ( )
virtual

Is the character touching the floor/ ground?

virtual bool plyGame.CharacterControllerBase.IsPlayer ( )
virtual

Derived class must override this to tell plyGame if this controller (Character) is a player character controller or non-player character (NPC).

Reimplemented in plyGame.PlayerBaseController.

virtual Vector3 plyGame.CharacterControllerBase.Movement ( )
virtual

The calculated move vector. Needed by animation controllers that controls root motion, like the basic mecanim controller.

virtual bool plyGame.CharacterControllerBase.MovementControlAllowed ( )
virtual

Return true if the character may accept input to generate movement

Reimplemented in plyGame.PlayerBaseController.

virtual float plyGame.CharacterControllerBase.MoveSpeed ( )
virtual

Return the current move speed being used. This defaults to returning moveSpeed but some controllers might override this if they have other movement speed types, for example running during a chase.

virtual void plyGame.CharacterControllerBase.OnDeath ( )
virtual

Called when the character is killed. Call base.Death() if you override this.

virtual bool plyGame.CharacterControllerBase.RequestFaceDirection ( Vector3  direction,
float  delayAfter 
)
virtual

Turn the character to face in direction. Return false if this character controller do not accept requests to turn. Actor uses this to ask the character to look in direction it needs to perform a skill. The delayAfter determine how long the character will face the target direction, after reaching it and before returning to viewing in direction it is moving (if moving).

virtual bool plyGame.CharacterControllerBase.RequestLookAt ( Vector3  position,
float  delayAfter 
)
virtual

Turn the character to face the target location (position). Return false if this character controller do not accept requests to turn. Actor uses this to ask the character to look in a direction to perform skill. The delayAfter determine how long the character will face the target direction, after reaching it and before returning to viewing in direction is is moving (if moving).

virtual bool plyGame.CharacterControllerBase.RequestMoveTo ( Vector3  position,
bool  useFasterMovement 
)
virtual

Move the character to position. Return false if this character controller do not accept requests to move. Actor uses this to ask the character to move, for example when it needs the character to move closer to selected target or to perform a skill.

Parameters
positionThe position to move to
useFasterMovementA hint that a run speed should be used if the character supports it
void plyGame.CharacterControllerBase.SelectTarget ( GameObject  go)

Called when a target is selected. et the selected target. If null or passed object is not a Targetable, then the selected target will be cleared. You should call base.SelectTarget() if you override this.

virtual void plyGame.CharacterControllerBase.SelectTarget ( Targetable  t)
virtual

Called when a target is selected. If null then the selected target will be cleared. You should call base.SelectTarget() if you override this.

virtual void plyGame.CharacterControllerBase.SetMoveSpeed ( float  speed)
virtual

Set the movement speed of the character

virtual void plyGame.CharacterControllerBase.SetTargetInteract ( GameObject  go)
virtual

The gameObject as target interact. The character will try to move to it and face it before the Interact related events are triggered.

virtual void plyGame.CharacterControllerBase.SetTargetInteract ( Targetable  t)
virtual

The character will try to move to it and face it before the Interact related events are triggered.

virtual void plyGame.CharacterControllerBase.SetTurnSpeed ( float  speed)
virtual

Set the turn speed of the character

virtual void plyGame.CharacterControllerBase.Stop ( )
virtual

Ask character to stop moving and/ or turning

virtual void plyGame.CharacterControllerBase.StopAll ( )
virtual

Ask character to stop. Removing queued targets and stop moving.

virtual void plyGame.CharacterControllerBase.StopInteract ( )
virtual

Trigger event on currently active interact

override Type plyGame.CharacterControllerBase.TargetableType ( )
virtual

You will not need to override this in a base class as it already returns Type.Character.

Reimplemented from plyGame.Targetable.

virtual float plyGame.CharacterControllerBase.TurnSpeed ( )
virtual

Return the current turn speed being used. This defaults to returning turnSpeed but some controllers might override this if they have other movement speed types, for example running during a chase.

virtual Vector3 plyGame.CharacterControllerBase.Velocity ( )
virtual

Character's current velocity

Property Documentation

Transform plyGame.CharacterControllerBase._tr
getset

The Transform component of the character

Actor plyGame.CharacterControllerBase.actor
getset

The Actor component of the character

bool plyGame.CharacterControllerBase.controlEnabled
getset

Is control of the character enabled? Player characters should not accept input and an NPC's I should be off when this is false.

bool plyGame.CharacterControllerBase.hint_DoNotMove
getset

If set then the character should not move. Normally set by actor when a skill being used do not allow movement.

bool plyGame.CharacterControllerBase.Interacting
get

True while the character is "interacting" with something. StopInteract() must be called to stop it.

Targetable plyGame.CharacterControllerBase.queuedInteract
getset

The object queued to be interacted with once character is in range and facing it.

Targetable plyGame.CharacterControllerBase.selectedTarget
getset

This character's currently selected Targetable object. For player controllers this would be what the player clicked on (characters, items and objects) last and for NPCs this would be what the AI selected (only other characters)