

Tried not to change your script too much. Can anybody help? Script: (block) Project: Hope this helps. The issue is, however, that the thing I'm trying to get to bounce (a bullet) will sometimes just vibrate along or through a wall. My current script (a slightly edited version of the block workaround for the “if on edge, bounce” block. Feel free to remix it or backpack it for use (but give credit).Roboguy99 wrote:So I'm trying to make something bounce properly but am having some troubles as to doing so. 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. It falls if it is not colliding otherwise it stops.

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. Things also slow down due to air resistance. 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.

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. To create gravity in scratch we first need to understand how gravity acts in the real world.
