Table of Contents

,

Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorNStateLocomotion

ECBehaviorNStateLocomotion

Behavior element behavior adding locomotion state support.

If ECBehaviorNetworkState is present and activate adds network values to synchronize ECBehaviorLocomotion certain values.

Instance Counts

This behavior can be used only once on an element.

Element Class Properties

Element class properties have the prefix nstateLocomotion. .

Events

This behavior has no events.

Required Behaviors

Optional Behaviors

This behavior does not support optional behaviors.

Persistency

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

API Documentation

ECBehaviorNStateLocomotion.

Since DragonScript Module Version 1.0

Use Cases

Element Class Example

This example defines an element which can synchronize locomotion state using network state.

class MyElement extends BehaviorElementClass
  public var ECBehaviorComponent component
  public var ECBehaviorCollider collider
  public var ECBehaviorColliderAI colliderAI
  public var ECBehaviorLocomotion locomotion
  public var ECBehaviorNetworkState networkState
  public var ECBehaviorNStateLocomotion nstateLocomotion
  func new()
    component = ECBehaviorComponent.new(this, null)
    collider = ECBehaviorCollider.new(this, component)
    colliderAI = ECBehaviorColliderAI.new(this, collider)
    locomotion = ECBehaviorLocomotion.new(this, colliderAI)
    networkState = ECBehaviorNetworkState.new(this, 1, 1)
    nstateLocomotion = ECBehaviorNStateLocomotion.new(this, locomotion, networkState)
  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='ECBehaviorComponent'/>
  <behavior type='ECBehaviorCollider'/>
  <behavior type='ECBehaviorColliderAI'/>
  <behavior type='ECBehaviorLocomotion'/>
  <behavior type='ECBehaviorNetworkState'>
    <integer name='requestLinkCode'>1</integer>
    <integer name='messageCode'>1</integer>
  </behavior>
 
  <behavior type='ECBehaviorNStateLocomotion'>
    <!-- optional: orientation precision. default is 1 -->
    <float name='precisionOrientation'>0.1</float>
 
    <!-- optional: looking precision. default is 1 -->
    <float name='precisionLooking'>0.1</float>
 
    <!-- optional: turning speed precision. default is 1 -->
    <float name='precisionTurningSpeed'>0.1</float>
 
    <!-- optional: turn in place precision. default is 1 -->
    <float name='precisionTurnInPlace'>0.1</float>
 
    <!-- optional: linear velocity precision. default is 1 -->
    <float name='precisionLinearVelocity'>0.1</float>
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <string name='.name'>value</string>
  </behavior>
</elementClass>

Live Examples