Class AIDestinationSetter Extends VersionedMonoBehaviour, IComponentData, IRuntimeBaker

Public

Sets the destination of an AI to the position of a specified object.

This component should be attached to a GameObject together with a movement script such as AIPath, RichAI or AILerp. This component will then make the AI move towards the target set on this component.

Essentially the only thing this component does is to set the Pathfinding.IAstarAI.destination property to the position of the target every frame. There is some additional complexity to make sure that the destination is updated immediately before the AI searches for a path as well, in case the target moved since the last Update. There is also some complexity to reduce the performance impact, by using the BatchedEvents system to process all AIDestinationSetter components in a single batch.

When using ECS, this component is instead added as a managed component to the entity. The destination syncing is then handled by the SyncDestinationTransformSystem for better performance.

Public Variables

target

The object that the AI should move to.

Public
useRotation

If true, the agent will try to align itself with the rotation of the target.

Public

Private/Protected Members

Awake ()
Protected
OnCreatedEntity (world, entity)
Private
OnDisable ()
Private
OnEnable ()
Private
OnUpdate (components, count)

Updates the AI's destination every frame.

Private Static
OnUpgradeSerializedData (migrations, unityThread)

Handle serialization backwards compatibility.

Protected
Reset ()

Handle serialization backwards compatibility.

Protected
UpdateDestination ()

Updates the AI's destination immediately.

Private
UpgradeSerializedData (isUnityThread)
Protected
ai
Private
entity
Private
world
Private