User Tools

Site Tools


dragengine:modules:dragonscript:behavior_navigationblocker

ECBehaviorNavigationBlocker

Behavior element behavior adding navigation blocker support.

Behavior adds a NavigationBlocker resource to the the behavior element. This allow elements using Navigator resource to avoid moving into the blocked space. Actors have a navigator by default. Other elements can use ECBehaviorNavigator to interact with ECBehaviorNavigationBlocker.

If the ECBehaviorCollider behavior is present in the behavior element before this behavior is added the light is attached. The light is attached to the named bone if defined otherwise it is attached statically.

See also:

Instance Counts

This behavior can be added multiple times to an element. Each instance creates one navigation blocker attached to the element collider which can be individually modified. Use the behavior identifier to tell them apart.

Element Class Properties

Element class properties have the prefix navigationBlocker. or navigationBlocker({id}). if id is not empty.

layer

Set layer. Only spaces, blockers and navigators on the same layer affect each other.

  • Full name: navigationBlocker.layer or navigationBlocker({id}).layer
  • Type: integer
  • Default Value: 0
  • Example (*.deeclass)
    <integer name='navigationBlocker.layer'>1</integer>

shape

Set blocker shape. Carves space inside shape out of touching navigation spaces.

  • Full name: navigationBlocker.shape or navigationBlocker({id}).shape
  • Type: string (shape format). See “Shape List Encoding” in CodecPropertyString.
  • Default Value: empty string
  • Example (*.deeclass)
    <string name='navigationBlocker.shape'>box:position,0,0.5,0:extends,2,1,0.5</string>

priority

Set priority. Blockers only carve space out of navigation spaces with the same priority or lower as the blocker priority.

  • Full name: navigationBlocker.priority or navigationBlocker({id}).priority
  • Type: integer
  • Default Value: 0
  • Example (*.deeclass)
    <integer name='navigationBlocker.priority'>1</integer>

position

Set position to attach resource to collider.

  • Full name: navigationBlocker.position or navigationBlocker({id}).position
  • Type: 3-component float vector
  • Default Value: (0,0,0)
  • Example (*.deeclass)
    <vector name='navigationBlocker.position' x='0' y='0' z='0.1'/>

orientation

Set orientation to attach resource to collider in degrees.

  • Full name: navigationBlocker.orientation or navigationBlocker({id}).orientation
  • Type: 3-component float vector
  • Default Value: (0,0,0)
  • Example (*.deeclass)
    <vector name='navigationBlocker.orientation' x='30' y='0' z='0'/>

bone

Set bone to attach resource to. If empty string attach to collider.

  • Full name: navigationBlocker.bone or navigationBlocker({id}).bone
  • Type: string
  • Default Value: empty string
  • Example (*.deeclass)
    <string name='navigationBlocker.bone'>attach</string>

Events

This behavior has no events.

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

Persistency

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

API Documentation

ECBehaviorNavigationBlocker.

Since DragonScript Module Version 1.0

Use Cases

  • Prevent navigators moving across space covered by blocker shape.

Element Class Example

This example defines an element which contains a navigation blocker.

class MyElement extends BehaviorElementClass
  public var ECBehaviorComponent component
  public var ECBehaviorCollider collider
  public var ECBehaviorNavigationBlocker navigationBlocker
  func new()
    component = ECBehaviorComponent.new(this, null)
    collider = ECBehaviorCollider.new(this, component)
    navigationBlocker = ECBehaviorNavigationBlocker.new(this, collider)
    
    var ShapeList shape = ShapeList.new()
    shape.addBox(Vector.new(), Vector.new(0.6, 0.3, 0.3))
    navigationBlocker.getNavigationBlocker().getShape().setShape(shape)
  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='ECBehaviorNavigationBlocker'>
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <string name='.shape'>box:position,0,0.5,0:extends,2,1,0.5</string>
  </behavior>
 
  <!-- for adding multiple behaviors use unique identifiers -->
  <behavior type='ECBehaviorNavigationBlocker' id='second'/>
</elementClass>

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/behavior_navigationblocker.txt · Last modified: 2025/03/12 19:36 by dragonlord