Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » 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:
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 have the prefix navigationSpace.
or navigationSpace({id}).
if id is not empty.
Set layer. Only spaces, blockers and navigators on the same layer affect each other.
navigationSpace.layer
or navigationSpace({id}).layer
<integer name='navigationSpace.layer'>1</integer>
Set path to navigation space resource to use.
navigationSpace.path
or navigationSpace({id}).path
*.denavspace
<string name='navigationSpace.path'>room.denavspace</string>
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.
navigationSpace.snapDistance
or navigationSpace({id}).snapDistance
<float name='navigationSpace.snapDistance'>0.01</float>
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.
navigationSpace.blockerShape
or navigationSpace({id}).blockerShape
<string name='navigationSpace.blockerShape'>box:position,0,0.5,0:extends,2,1,0.5</string>
Set blocker priority. Blockers only carve space out of navigation spaces with the same priority or lower as the blocker priority.
navigationSpace.blockerPriority
or navigationSpace({id}).blockerPriority
<integer name='navigationSpace.blockerPriority'>1</integer>
Set position to attach resource to collider.
navigationSpace.position
or navigationSpace({id}).position
<vector name='navigationSpace.position' x='0' y='0' z='0.1'/>
Set orientation to attach resource to collider in degrees.
navigationSpace.orientation
or navigationSpace({id}).orientation
<vector name='navigationSpace.orientation' x='30' y='0' z='0'/>
Set bone to attach resource to. If empty string attach to collider.
navigationSpace.bone
or navigationSpace({id}).bone
<string name='navigationSpace.bone'>attach</string>
This behavior has no events.
This behavior requires no other behaviors.
This behavior does require the element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
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
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>