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.