When you're deciding on how best to move your player character around your virtual world, consider what's going to look the most realistic and not run your game into the ground with expensive computations. This is somewhat of a trade-off in most cases, and Unity is no different.
The three most common ways of moving GameObjects and their results are as follows:
- Option A: Use a GameObject's Transform component for movement and rotation. This is the easiest solution and the one we'll be working with first.
- Option B: Attach a Rigidbody component to a GameObject and apply force in code. This solution relies on Unity's physics system to do the heavy lifting, delivering a far more realistic effect. We'll update our code to use this approach later on in this chapter to get a feel for both methods.
Unity suggests sticking to a consistent approach when moving or rotating a GameObject; either manipulate an object's...