{{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]] >> **ECBehaviorRenderableCustomColor** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== ECBehaviorVRHand ====== {{youtube>8MOm97tG81o?medium}} Behavior in action Behavior element behavior adding VR Hand Controller support to actor. This behavior tracks one hand controller optionally displaying it on screen using either the developer provided model or a custom model. Optionally a rig can be assigned to get physical presence of the controller in the game world. ====== Instance Counts ====== This behavior can be added twice to an element to add support for left and right hand controller. Use the behavior identifier to tell them apart. ====== Element Class Properties ====== Element class properties have the prefix ''vrHand.'' or ''vrHand(id).'' if id is not empty. ===== useVendorModel ===== Determines if the Vendor Specific 3D Model is used to show the device. The Vendor Specific 3D Model is provided by the VR Runtime installation. If set to false ''vrHand(id).component.*'' properties can be used to define the model to use. * Full name: ''vrHand.useVendorModel'' or ''vrHand(id).useVendorModel'' * Type: boolean * Default Value: ''true'' * Example (*.deeclass): false ===== showHand ===== Determines if the device is shown in the 3D view. Set this to true if you use a separate model to show the hands. Set to false if you use the regular animated actor support to animate the hands using the hand position and orientation as input. * Full name: ''vrHand.showHand'' or ''vrHand(id).showHand'' * Type: boolean * Default value: ''true'' * Example (*.deeclass): false ===== component.* ===== This behavior adds a child [[behavior_component|ECBehaviorComponent]] to the element class to show the hand in the game world. The child behavior has the identifier ''vrHand'' or ''vrHand(id)''. The child behavior has the element class property prefix ''vrHand.component.'' or ''vrHand(id).component.'' . Hence to set for example the component model of the right hand use the element class property ''vrHand(right).component.model'' . ====== Events ====== ===== controllerAttached ===== Hand controller attached and ready to use. ===== controllerDetached ===== Hand controller detached and no more usable. ====== Behavior Tree Actions ====== This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace ''vrHand'' with ''vrHand(id)''. ===== vrHand.check ===== Check one or more VR hand parameters. Action succeeds if all parameter value matches their respective VR hand parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a VR hand parameter matches (or not). ^Parameter^Value^Description^ |attached|''true'', ''false''|VR controller is attached| |wait| |If present action returns BTResult.running instead of BTResult.failed to wait until the checks are all fulfilled| This is an example of using this action: true ====== Behavior Tree Conditions ====== This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace ''vrHand'' with ''vrHand(id)''. ===== vrHand.check ===== Check one or more VR hand parameters. Conditions returns true if all parameter value match their respective VR hand parameter. This condition is typically used to run an action or sequence of actions as long as VR hand conditions are true. ^Parameter^Value^Description^ |vrHand.attached|''true'', ''false''|VR controller is attached| This is an example of using this condition: true vrHand.check ====== State Machine Actions ====== Same as [[#behavior_tree_actions|Behavior Tree Actions]]. ====== State Machine Conditions ====== Same as [[#behavior_tree_conditions|Behavior Tree Conditions]]. ====== State Machine Events ====== This behavior sends these state machine events. If behavior has non-empty identifier replace ''vrHand'' with ''vrHand(id)''. ===== vrHand.attached ===== VR controller has been attached. ===== vrHand.disabled ===== VR controller has been detached. ====== Required Behaviors ====== * [[behavior_vrplayspace|ECBehaviorVRPlayspace]] ====== Optional Behaviors ====== * [[behavior_behaviortree|ECBehaviorBehaviorTree]]: Add actions and conditions for behavior trees to use. * [[behavior_statemachine|ECBehaviorStateMachine]]: Add actions and conditions for state machine to use and events to send to the state machine. ====== Persistency ====== This behavior does not use persistency. ====== API Documentation ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorVRHand.html,ECBehaviorVRHand~@#. Since DragonScript Module Version ''1.6'' ====== Use Cases ====== * Apply custom colors chosen by player to his player actor. ====== Element Class Example ====== The following example creates an element class with two hand controllers. class MyElement extends BehaviorElementClass func new() // Add VR Playspace behavior. Base behavior required by all VR behaviors var ECBehaviorVRPlayspace vrPlayspace = ECBehaviorVRPlayspace.new(this) // Add VR HMD behavior. With this behavior present VRPlayerControlledActorCameraDirector // can attach the HMD to the in-game camera ECBehaviorVRHMD.new(this, vrPlayspace) // Add left and right hand controller. The InputDeviceType is required // for the behavior to know which input device to monitor ECBehaviorVRHand.new(this, vrPlayspace, InputDeviceType.vrRightHand, "right") ECBehaviorVRHand.new(this, vrPlayspace, InputDeviceType.vrLeftHand, "left") end end ====== Behavior Factory ====== Using element class supporting adding behaviors the behavior can be added like this: vrRightHand default 6:0 1 2 3 5 default default true ... ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]: ExampleVR project. * [[https://github.com/LordOfDragons/dragengine/blob/master/src/modules/scripting/dragonscript/scripts/scenery/actor/BaseVRActorClass.ds|BaseVRActorClass]]: Base class for VR actors