- Unity 2018 Artificial Intelligence Cookbook(Second Edition)
- Jorge Palacios
- 87字
- 2021-07-16 18:11:28
Getting ready
We must add a new member variable to our AgentBehaviour class called weight and preferably assign a default value. In this case, this is 1.0f. We should refactor the Update function to incorporate weight as a parameter for the Agent class's SetSteering function. All in all, the new AgentBehaviour class should look something like this:
public class AgentBehaviour : MonoBehaviour { public float weight = 1.0f; // ... the rest of the class public virtual void Update () { agent.SetSteering(GetSteering(), weight); } }