- Unity 2018 Artificial Intelligence Cookbook(Second Edition)
- Jorge Palacios
- 83字
- 2021-07-16 18:11:29
Getting ready
This approach is very similar to the one used in the previous recipe. We must add a new member variable to our AgentBehaviour class. We should also refactor the Update function to incorporate priority as a parameter to the Agent class's SetSteering function. The new AgentBehaviour class should look something like this:
public class AgentBehaviour : MonoBehaviour { public int priority = 1; // ... everything else stays the same public virtual void Update () { agent.SetSteering(GetSteering(), priority); } }