Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorPlayerControllable
Behavior element behavior adding player controlling support to actor.
Actors with this behavior can become the player controlled actor. Requires an instance of ECBehaviorPlayerControllable.Tracker
to be assigned. The instance keeps track of the active player actor and is typically stored globally in the game. BaseGameApp provides such an instance for easy use.
This behavior can be used only once on an element.
Element class properties have the prefix playerControllable.
.
Became active player actor.
Ceased being active player actor.
playerControllable takeControl
Make actor become the active player actor.
playerControllable isPlayerControlled
Actor is the active player actor.
This behavior requires no other behaviors.
This behavior does support element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
This example defines an element which can be controlled by the player.
class MyElement extends BehaviorElementClass public var ECBehaviorPlayerControllable playerControllable func new() playerControllable = ECBehaviorPlayerControllable.new(this) end end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorComponent'/> <behavior type='ECBehaviorCollider'/> <behavior type='ECBehaviorPlayerControllable'> <!-- optional: use BaseGameApp player controlled actor. game can add more supported values. default is 'default' --> <string name='playerControlledActor'>default</string> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.name'>value</string> </behavior> </elementClass>