How to create simple gravity!



Hey guys! Today I am going to show you how to make simple gravity in Hopscotch!
Now, usually when making gravity, the tendency is to just make a repeat forever block with a change y by -8 in it. While this works, it looks more like the character is being pushed down then falling naturally. We need something called acceleration.

Setting up the project

So how will we do that? Well first we need to create a character. I picked cosmic cody.

Next we need to create a new rule. For this tutorial I chose when the play button is tapped, but it can be whenever you want to "turn on" gravity.

Now we have our project set up, and it is time to start...


We will start out with a repeat forever block.*

Next, create a new value. You can call it whatever you want, but I called mine "gravity"
Inside the repeat forever block decrease the value you created by -1. This makes acceleration, so that the character speeds up as it falls.

And lastly, also inside the repeat forever block change the y value of the character by gravity!

And there you have it! We just sent cosmic cody into freefall!

*If you only want gravity to be on under certain conditions surround everything inside the repeat forever block with a check once if to see if those conditions are met.

How to make physics in hopscotch

Great tutorial @BuildASnowman. Very clear, and is easy to follow. Thanks, now I can use this in future projects! :grinning:


Great work! I love the pictures you have used very clear. A next step is to make a link saying what it looks like. Pretty good though. I will try this in future projects.


How come it's -1? Don't you need it to increase to make him fall faster and faster?


You need to decrease the number to make the object go down faster and faster, I can teach you even more about physics in Hopscotch. Their is no real decrease block, but I would like it.


@Phase_Studios......the bigger the number, the farther it goes. The farther it goes, the faster it is.........?


What @BuildASnowman said, he is right. He is right because the gravity really needs to decrease to make the Y postion fall down to make it simmulate real gravity. It keeps on decreasing the gravity value so it will get faster.