Simple Gravity

Lesson

Simple Gravity

Many projects such as Platformers or anything involving jumping require gravity to work realistically. This tutorial will go over how to use it.

Without worrying about the actual physics involved we need to have a variable called velocity which stores how fast the sprite is moving and if it’s moving up or down. We then want to subtract a number to act like gravity, the bigger the number the stronger the gravity.

Once the sprite touches the colour black which is acting as the ground we set the velocity back to 0 as it can’t go any lower.

Have a look at and try out the example code. Play around with different numbers for velocity to see what happens as they get bigger and smaller

https://scratch.mit.edu/projects/352271277/editor/

@

Not recently active