Physics basics: Set gravity, start physics

Edited

Let’s take a look at how to start physics and create gravity in Tynker. Add an actor of your choice to your project (Add Actor > Media Library), then give your actor this code:

You only need to use the start physics block once in your project, and physics will be enabled for all actors.

Notice how the set gravity block has two parameters, one for the x direction (left-to-right), and another for the y direction (up-and-down). The code snippet above gives gravity of 10 in the y direction, meaning objects will accelerate straight downward. Like the start physics block, set gravity affects all actors.

When you play your project, you should see your actor fall to the ground. Cool! Try changing gravity in your project and watch what happens.

ball-drop.gif