User Tools

Site Tools


dragengine:modules:dragonscript:behavior_playerinputcrouch

ECBehaviorPlayerInputCrouch

Behavior element behavior adding crouching player input.

Keeps track of crouching player input and applies them to actor locomotion.

Instance Counts

This behavior can be used only once on an element.

Element Class Properties

Element class properties have the prefix playerInputCrouch. .

Events

This behavior has no events.

Behavior Tree Actions

This behavior adds these behavior tree actions if behavior tree is present.

playerInputCrouch.set

Set one or more player input crouch parameters.

ParameterValueDescription
reset Reset player input crouch
crouchtrue, falseCrouch key pressed
crouch.toggle Toggle crouch key pressed
canCrouchtrue, falseCan crouch
canCrouch.toggle Toggle can crouch
stancefloatStance value in the range from 0 to 1

This is an example of using this action:

<action name='playerInputCrouch.set'>
  <parameter name='crouch'>true</parameter>
</action>

playerInputCrouch.update

Update player input crouch.

ParameterValueDescription
locomotion Update locomotion using ECBehaviorLocomotion.setStanceGoal()

This is an example of using this action:

<action name='playerInputCrouch.update'>
  <parameter name='locomotion'/>
</action>

playerInputCrouch.check

Check one or more player input crouch parameters. Action succeeds if all parameter value matches their respective player input crouch parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a player input crouch parameter matches (or not).

ParameterValueDescription
crouchtrue, falseCrouch key pressed
canCrouchtrue, falseCan crouch
stance.lessfloatStance is less than float value
stance.greaterfloatStance is greater than float value
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:

<sequence>
  <action name='playerInputCrouch.check'>
    <parameter name='crouch'>true</parameter>
  </action>
  <!-- actions here run only if crouch key is pressed -->
</sequence>

Behavior Tree Conditions

This behavior adds these behavior tree conditions if behavior tree is present.

playerInputCrouch.check

Check one or more player input crouch parameters. Conditions returns true if all parameter value match their respective player input crouch parameter. This condition is typically used to run an action or sequence of actions as long as player input crouch conditions are true.

ParameterValueDescription
crouchtrue, falseCrouch key pressed
canCrouchtrue, falseCan crouch
stance.lessfloatStance is less than float value
stance.greaterfloatStance is greater than float value

This is an example of using this condition:

<action name='myAction' id='doing something'>
  <parameter name='playerInputCrouch.crouch'>true</parameter>
  <condition>playerInputCrouch.check</condition>
</action>

State Machine Actions

State Machine Conditions

State Machine Events

This behavior send no events to state machine.

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

Persistency

This behavior does support element class to be persistable (setPersistable).

API Documentation

ECBehaviorPlayerInputCrouch.

Since DragonScript Module Version 1.0

Use Cases

  • Track player input for crouching

Element Class Example

This example defines an element which tracks player crouching input.

class MyElement extends BehaviorElementClass
  public var ECBehaviorPlayerInputCrouch playerInputCrouch
  func new()
    playerInputCrouch = ECBehaviorPlayerInputCrouch.new(this)
  end
end

Behavior Factory

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='ECBehaviorPlayerInputCrouch'>
    <!-- optional: use behavior tree with id instead of empty string -->
    <string name='behaviorTree'>second</string>
 
    <!-- optional: use state machine with id instead of empty string -->
    <string name='stateMachine'>second</string>
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <string name='.name'>value</string>
  </behavior>
</elementClass>

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/behavior_playerinputcrouch.txt · Last modified: 2025/05/09 14:16 by dragonlord