Table of Contents

,

Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorNavigationSpace

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.

path

Set path to navigation space resource to use.

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.

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.

blockerPriority

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

position

Set position to attach resource to collider.

orientation

Set orientation to attach resource to collider in degrees.

bone

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

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

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