Player GameObject - Jump
Last updated
Last updated
In order to use the following script to enable your player to jump, the following changes must be configured in Unity before the following script will work
Create a new Layer: Ground in the Unity Layer Editor. All gameObjects which will act as ground, (example: Floor) to allow jumping, must have this layer set in the inspector. See image below
Create an empty gameObject, rename to Floor Add BoxCollider2D as shown in image below Select and icon for the gameObject - select in top section of inspector - example green oval Set Layer: Ground, after following directions to create custom layers below.
Set Layer: Ground
GroundCheck: Create an empty gameObject, make it a child of the Player, name: GroundCheck. Add an icon (blue capsule in the image ), so it's easy to see. Move the GroundCheck gameObject to the bottom of the player's feet, this gameObject will check to see if it's in contact with a gameObject that is in the 'Ground' layer.