Lesson 2
Falling down: gravity
Give things weight with a Physics Body, and make ground they can land on.
Draft lesson: nobody has followed it from start to finish in the editor yet, so a step may not match what you see.
Video coming soon
We are making a video for this lesson. For now, follow the steps below!
In this lesson you will
- Give a GameObject a shape
- Make it fall with a Physics Body
- Make ground that stays still
What you will make
A player that falls and lands on the ground.
1. Give the player a shape
Click Player. Click Add Component and add a Box Collider. That is its shape: the part
that can touch other things.
2. Give it weight
Click Add Component again and add a Physics Body. If your level has no physics yet, the editor adds it for you.
3. Make the ground
- Make a sprite called
Ground, below the player. Make it wide. - Add a Box Collider and a Physics Body to it too.
- In its Physics Body, make it Static. Static means it never moves.
4. Play!
Press Play. The player falls and lands on the ground!
See the shapes
Click View, then Show colliders. Now you can see every shape. Do they match your pictures?
Careful!
With a Physics Body, the physics moves the player. Changing its Position in code does not work any more. In the next lesson you will move it the physics way.
Try this
- Forget to make the ground Static. What happens?
- Add a box that falls on the player.
Try it here
Your mission
Make the ground Static, press Play, and watch the player land.
Soon, a small piece of the editor will be right here, so you can practise without leaving the lesson. For now, try it in the editor!