Adding jumps
Remember from the last chapter that Rigidbody components add simulated real-world physics to GameObjects, and Collider components interact with each other using Rigidbody objects.
Another great thing that we didn’t discuss in the previous chapter about using a Rigidbody component to control player movement is that we can easily add in different mechanics that rely on applied force, such as jumping. In this section, we’ll get our player jumping and write our first utility function.
A utility function is a class method that performs some kind of grunt work so that we don’t clutter up gameplay code—for instance, wanting to check whether the player capsule is touching the ground to jump.
Before that, you’ll need to get acquainted with a new data type called enumerations, which you’ll do in the following section.
Introducing enumerations
By definition, an enumeration type is a set, or collection, of...