{{tag>dragonscript behavior}}
[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorAvoidedByActor**
* [[behaviors_use_cases|Behaviors Explained: By Use-Case]]
* [[behaviors_a_to_z|Behaviors Explained: From A to Z]]
====== 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)
===== size =====
Set size.
* Full name: "avoidedByActor.size" or "avoidedByActor({id}).size"
* Type: 2-component float vector
* Default Value: (0,0)
* Example (*.deeclass)
===== 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) 90
===== radius =====
Set radius.
* Full name: "avoidedByActor.radius" or "avoidedByActor({id}).radius"
* Type: float
* Default Value: 0
* Restriction: 0 or larger
* Example (*.deeclass) 0.4
====== 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 ======
#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorAvoidedByActor.html,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:
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]