This section documents the Clean Engine class _CharacterMoveState, and explains how to use this class to get information about what a player controlled character is doing.
Nodes using _CharacterMoveState
While the default HeroEngine character controller is used, the system methods attach a class named _CharacterMoveState to the node representing the player's character upon logging in. This gives this node methods that can be used to find the current state of the character.
As movement messages are received from the client, the fields in _CharacterMoveState are updated with the values of the last movement packet.
method _getPosition() as Vector3
This method returns the last position given to the server for the character.
method _IsCharacterMoving() as Boolean
This method returns true if the character is currently in a moving state, or false if the character is not currently moving.
method _predictPosition(secondsFromNow as Float) as Vector3
This method predicts the position of the character in the future, extrapolating from the last movement packet the client sent.
Note: This method is currently unimplemented.
Method Usage Example
function InfoAboutCharacter(character as noderef of class _CharacterMoveState) if character._IsCharacterMoving() $CHAT.CHATAREA("default", "The character is moving") else $CHAT.CHATAREA("default", "The character is not moving") . $CHAT.CHATAREA("default", "The character is at position " + character._getPosition()) futureTime as Float = 2.0 $CHAT.CHATAREA("default", "The character might be at " + character_predictPostion(futureTime) + " in " + futureTime + " seconds") .
When any state in the movement state changes values, an event is triggered. If there is a class on the character that implements
method HE_moveStateChangedthat method will be called during this event.
This is a method implementation that can be placed in a class which is glommed onto, or inherited onto the character node.
method HE_moveStateChanged() where me is kindof _CharacterMoveState if me._IsCharacterMoving() $CHAT.CHATAREA("default", "I'm not sure what the player was doing before, but he's moving now.") else $CHAT.CHATAREA("default", "The player is definately not moving right now, offer him a cookie.") . . default $CHAT.CHATAREA("default", "This can't possibly happen") . . .
- $CHARACTERSELECTIONSYSTEM- Handles the addition of the CharacterMoveState class in an overrideable fashion.