User Tools

Site Tools


dragengine:modules:dragonscript:behavior_avoidedbyactor

ECBehaviorAvoidedByActor

Behavior adding support to elements to be avoided by actors.

Avoid shape is defined by position, half-size and radius. This allows to model spheres and round boxes as avoid shapes projected to the ground. The behavior can be enabled and disabled to allow define avoid shapes activate only at specific times. Although not prohibited shapes should not move to allow behaviors doing avoiding to work the best way possible.

Instance Counts

This behavior can be added multiple times to add multiple avoid shapes. Use the behavior identifier to tell them apart.

Element Class Properties

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

origin

Set origin relative to element.

  • Full name: “avoidedByActor.origin” or “avoidedByActor({id}).origin”
  • Type: 3-component float vector
  • Default Value: (0,0,0)
  • Example (*.deeclass)
    <vector name='avoidedByActor.origin' x='0' y='0' z='0.3'>

size

Set size.

  • Full name: “avoidedByActor.size” or “avoidedByActor({id}).size”
  • Type: 2-component float vector
  • Default Value: (0,0)
  • Example (*.deeclass)
    <vector2 name='avoidedByActor.size' x='0.6' y='0.4'/>

orientation

Set orientation along world Y axis relative to element world Y orientation.

  • Full name: “avoidedByActor.orientation” or “avoidedByActor({id}).orientation”
  • Type: float
  • Default Value: 0
  • Example (*.deeclass)
    <float name='avoidedByActor.orientation'>90</float>

radius

Set radius.

  • Full name: “avoidedByActor.radius” or “avoidedByActor({id}).radius”
  • Type: float
  • Default Value: 0
  • Restriction: 0 or larger
  • Example (*.deeclass)
    <float name='avoidedByActor.radius'>0.4</float>

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

ECBehaviorAvoidedByActor.

Since DragonScript Module Version 1.0

Use Cases

  • Make actor avoid a static obstacle without using navigation blockers.
  • Make actor avoid a moving obstacle.

Element Class Example

This example defines an element actors avoid. The avoid shape is a box shape with round corners.

class MyElement extends BehaviorElementClass
  public var ECBehaviorAvoidedByActor avoidedByActor
  public func new()
    avoidedByActor = ECBehaviorAvoidedByActor.new(this)
    avoidedByActor.getOrigin().setVector(Vector.new(0, 0, 0.3))
    avoidedByActor.getSize().setVector2(Vector2.new(0.6, 0.3))
    avoidedByActor.getRadius().setValue(0.3)
  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='ECBehaviorAvoidedByActor'/>
</elementClass>

Live Examples

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