{{tag>dragonscript behavior}}
[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorColliderAI**
* [[behaviors_use_cases|Behaviors Explained: By Use-Case]]
* [[behaviors_a_to_z|Behaviors Explained: From A to Z]]
====== ECBehaviorColliderAI ======
Behavior element behavior adding collider support suitable for actor AI.
ECBehaviorColliderAI adds a collider which is useable for actor AI usage. This collider is not linked to [[behavior_component|ECBehaviorComponent]] but instead creates a ColliderVolume. The shape of the collider can be set manually or obtained from Rig resources. Using shapes from rig resources is usually the simpler way while creating shapes allows for greater flexibility. Otherwise the classes behave similar.
ECBehaviorColliderAI requires [[behavior_collider|ECBehaviorCollider]]. Do not use this behavior if other behaviors try to move the [[behavior_collider|ECBehaviorCollider]]. Doing so can produce strange results. Apply velocities and changes to the AI collider.
In contrary to [[behavior_collider|ECBehaviorCollider]] this behavior does synchronize position with the element position but not vice versa. Actors typically have complex requirements on how their AI collider can move including projecting down to the ground after physics processing has finished. Behaviors suitable for managing collider AI typically update the AI collider velocities during think() and update element position and orientation from AI collider during postThink().
See also:
* [[gamedev:colliders|Colliders]]
====== Instance Counts ======
This behavior can be used only once on an element.
====== Element Class Properties ======
Element class properties have the prefix ''colliderAI.'' .
====== Events ======
This behavior has these events:
===== collisionResponse =====
Collision detected.
===== canHitCollider =====
Collision between colliders is possible. Only send if callback is enabled in collider AI. Stops after the first listener returning false. All listeneres added after this listener will not be called.
===== colliderChanged =====
Collider changed.
====== Required Behaviors ======
* [[behavior_collider|ECBehaviorCollider]]
====== Optional Behaviors ======
This behavior does not support optional behaviors.
====== Persistency ======
This behavior does support element class to be persistable (setPersistable).
====== API Documentation ======
#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorColliderAI.html,ECBehaviorColliderAI~@#.
Since DragonScript Module Version ''1.0''
====== Use Cases ======
* Allow actor to style his player actor using custom colors for individual body parts.
* Create variations of NPCs by adding color slots that can be modified in XML Element Classes or using Stub Properties.
====== Element Class Example ======
This example defines an element which contains a resources.
class MyElement extends BehaviorElementClass
public var ECBehaviorComponent component
public var ECBehaviorCollider collider
public var ECBehaviorColliderAI colliderAI
func new()
component = ECBehaviorComponent.new(this, null)
collider = ECBehaviorCollider.new(this, component)
colliderAI = ECBehaviorColliderAI.new(this, collider)
end
end
====== Behavior Factory ======
Using element class supporting adding behaviors the behavior can be added like this:
3:0 1 2 3 4
value
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]