{{tag>dragonscript behavior}}
[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[dragengine:modules:dragonscript:abstractions|Abstraction Layers: How you want to build your Game]] >> [[dragengine:modules:dragonscript:behavior_elements|Behavior Elements]] >> **ECBehaviorPlayerControllable**
* [[behaviors_use_cases|Behaviors Explained: By Use-Case]]
* [[behaviors_a_to_z|Behaviors Explained: From A to Z]]
====== 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.
====== Instance Counts ======
This behavior can be used only once on an element.
====== Element Class Properties ======
Element class properties have the prefix ''playerControllable.'' .
====== Events ======
===== playerTakesControl =====
Became active player actor.
===== playerReleasesControl =====
Ceased being active player actor.
====== Conversation Commands ======
===== playerControllable =====
''playerControllable takeControl''
Make actor become the active player actor.
====== Conversation Conditions ======
===== playerControllable =====
''playerControllable isPlayerControlled''
Actor is the active player actor.
====== Required Behaviors ======
This behavior requires no other behaviors.
====== Optional Behaviors ======
* [[behavior_conversationactor|ECBehaviorConversationActor]]: Add conversation commands and conditions
====== Persistency ======
This behavior does support element class to be persistable (setPersistable).
====== API Documentation ======
#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorPlayerControllable.html,ECBehaviorPlayerControllable~@#.
Since DragonScript Module Version ''1.0''
====== Use Cases ======
* Allow element to be controlled by player.
====== Element Class Example ======
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
====== Behavior Factory ======
Using element class supporting adding behaviors the behavior can be added like this:
default
value
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]