
Feel free to remix it or backpack it for use (but give credit). 0.9.Īttach this into the forever loop deleting the previous gravity code.īig thanks to Jimmyrooster for writing this article. To make it bounce, you would set the y velocity to Y velocity multiplied by a negative number e.g. Now we discover a way to make our circle bounce at the borders The. It falls if it is not colliding otherwise it stops. In the past, when our animated circle reached the border it jumped to the opposite border. You want an if else block with a condition for hitting something in the slot at the top a set Y Velocity to 0 block in the first gap and the gravity code in the else. Let’s say when the thing collides it stops. Create another sprite or colour for the object to collide with.

Set to ((Y Velocity) * (-8))Īnd finally, there is collision. We will add this code into the forever loop. For this I just set Y Velocity to 80% (multiplied by 0.8) of what it was. Scripts are where you make things happen They are made up of sequences of action (blocks).
ifThings also slow down due to air resistance. The active characters of a Scratch program are called Sprites. Making a sprite do something if it touches a color, e.g., if the sprite touches blue (water), it reacts in a specific way. To make gravity we need to add a change Y Velocity by block and put a negative number in (so the sprite goes down the screen). This is because Y Velocity stays at zero. To adjust the Smart Controls using the Touch Bar in Logic Pro: Buttons controlling levels (the button has a color line under the text indicating a slider). You probably want to attach a when green flag clicked block on top of this.

We want the y position of the sprite to change by its y velocity every frame.

Basic Physics in ScratchĬreate a sprite for the object you want to fall (or use one you already have).įirst, we will need to create a variable for the current velocity of the sprite. The earth will always be at the bottom of the screen. Most gravity will come from the earth - so we will ignore other objects. If you have an apple and you drop from high up what happens? Well the speed (or velocity) of the apple increases towards objects exerting gravity - in proportion to mass - until it reaches terminal velocity or hits something. Scratch needs to make a repeat unless block. To create gravity in scratch we first need to understand how gravity acts in the real world. Okay so I assume you have a gravity script, try making it so when it touches the color it sets the gravity making it bounce or fall down.
