- Unity 2018 Artificial Intelligence Cookbook(Second Edition)
- Jorge Palacios
- 73字
- 2021-07-16 18:11:23
How it works...
We added a member variable for storing the reference to a possible rigid body component, and also implemented FixedUpdate, similar to Update, but taking into consideration that we need to apply force to the rigid body instead of translating the object ourselves, because we're working on top of Unity's physics engine.
Finally, we created a simple validation at the beginning of each function so they're called only when it applies.