Z
Z
Zefirot2021-07-11 19:46:20
Unity
Zefirot, 2021-07-11 19:46:20

How does agent.SetDestination work?

Immediately I thought that agent.SetDestination should be in update, it turned out that it was enough for him to set a target and launch it at the start, and he would fly to the target ...
And how can he be stopped if necessary?
How to calculate that it intersected with another object, for example, this object also has the same agent.SetDestination movement, but if it collided with it, then the first object changes its target and flies after it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AnanasikDev, 2021-07-14
@AnanasikDev

agent.Stop() or agent.SetDestination(agent.transform.position) to stop the agent.
Well, this requires the usual OnTriggerEnter or OnCollisionEnter. Next, we determine whether it is an agent or not through GetComponent and change the target.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question