User Tools

Site Tools


dragengine:modules:dragonscript:bahavior_navigationspace

ECBehaviorNavigationSpace

Behavior element behavior adding navigation space and blocker support.

Behavior adds a NavigationSpace resource to the the behavior element. This allow elements using Navigator resource to move around the element. Actors have a navigator by default. Other elements can use ECBehaviorNavigator to interact with ECBehaviorNavigationSpace.

See also:

Instance Counts

This behavior can be added multiple times to an element. Each instance creates one navigation space attached to the element collider which can be individually modified

Element Class Properties

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

layer

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

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

path

Set path to navigation space resource to use.

  • Full name: navigationSpace.path or navigationSpace({id}).path
  • Type: string
  • Default Value: empty string
  • Expected File Pattern: *.denavspace
  • Example (*.deeclass)
    <string name='navigationSpace.path'>room.denavspace</string>

snapDistance

Set snap distance. If two navigation spaces nearly touch or overlap each other navigation points are aligned if they are closer than the snap distance. This does potentially modify points on navigation spaces but it ensures two separate navigation spaces turn into one large navigation space.

  • Full name: navigationSpace.snapDistance or navigationSpace({id}).snapDistance
  • Type: float
  • Default Value: 0.001
  • Restriction: At least 0.001
  • Example (*.deeclass)
    <float name='navigationSpace.snapDistance'>0.01</float>

blockerShape

Set blocker shape. Carves space inside shape out of touching navigation spaces. After carving out space the navigation space is merged with the other navigation spaces. This allows for example to add a passage way across navigation spaces by first carving out the stairs area and then merging the passage way navigation space with the underlaying navigation space. If done correctly placing such an element in the world makes navigators be automatically able to use the passage way properly.

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

blockerPriority

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

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

position

Set position to attach resource to collider.

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

orientation

Set orientation to attach resource to collider in degrees.

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

bone

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

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

Events

This behavior has no events.

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

Persistency

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

API Documentation

ECBehaviorNavigationSpace.

Since DragonScript Module Version 1.0

Use Cases

  • Add spaces navgiators can move along.
  • Add spaces connecting spaces by carving out first a blocker shape then merging for dynamic passages.

Element Class Example

This example defines an element which contains a navigation space.

class MyElement extends BehaviorElementClass
  public var ECBehaviorComponent component
  public var ECBehaviorCollider collider
  public var ECBehaviorNavigationSpace navigationSpace
  func new()
    component = ECBehaviorComponent.new(this, null)
    collider = ECBehaviorCollider.new(this, component)
    navigationSpace = ECBehaviorNavigationSpace.new(this, collider)
    navigationSpace.getNavigationSpace().getSpace().setPath("/content/navigation/floor.denavspace")
  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='ECBehaviorNavigationSpace'>
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <string name='.path'>floor.denavspace</string>
  </behavior>
 
  <!-- for adding multiple behaviors use unique identifiers -->
  <behavior type='ECBehaviorNavigationSpace' id='second'/>
</elementClass>

Live Examples

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