User Tools

Site Tools


dragengine:modules:dragonscript:behavior_anchorelement

ECBehaviorAnchorElement

Behavior element behavior adding anchor element support.

Anchoring elements allows to locate elements in a GameWorld using a unique name set by the mapper. This is useful for game commands send by conversations scripts.

Instance Counts

This behavior can be used only once on an element.

Element Class Properties

Element class properties have no prefix.

anchorID

Sets the anchor name or empty string to not anchor.

  • Full name: “anchorID”
  • Type: string
  • Default Value: empty string
  • Example (*.deeclass)
    <string name='anchorID'>Important Prop</string>

Events

This behavior has no events

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

This behavior does not support optional behaviors.

Persistency

This behavior does not require persistency.

API Documentation

ECBehaviorAnchorElement.

Since DragonScript Module Version 1.0

Use Cases

  • Reference elements in world editor using unique the anchor name.
  • Allow game scripts to locate an element in the game world using the anchor name.

Element Class Example

This example defines an element for which the user can set the anchor name in the world editor. He can then locate the element in the parent GameWorld using this anchor name.

class MyElement extends BehaviorElementClass
  public func new()
    ECBehaviorAnchorElement.new(this)
  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='ECBehaviorAnchorElement'/>
</elementClass>

Live Examples

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