Handling Collisions - Lakelands Computing

Title
Go to content
Handling Sprite Collisions
Handling Collisions is an important idea in animation and games.

A collision is what happens when two objects, such as two sprites, make contact with each other. That could be they just bump each other, or it could be a sprite walking into a door to open it, or a bullet hitting its target, or a sprite touching a football (to kick it).

The way it works in Scratch is - if touching this object -- do this thing...

One thing to be aware of an if statement runs once. It will run at the point it is started, so if it has a green flag event as its start point it will check if the objects are touching when the green flag is clicked. They probably won't be. To keep it actively checking so it reacts when there is a collision you need to put it in a loop (probably forever)

An alternative to using loops is to use Broadcast and When I receive  to trigger (call) the IF statement - it depends what you are making and how you want it to work.
All Text copyright Lakelands Academy & Mr T Purslow 2020.
All images copyright free / creative commons unless otherwise stated.
You are welcome to use under a Creative Commons Attribution-nonCommercial-ShareAlike License.
All Text copyright Lakelands Academy & Mr T Purslow 2020.  All images copyright free / creative commons unless otherwise stated. You are welcome to use under a Creative Commons Attribution-nonCommercial-ShareAlike License.
All Text copyright Lakelands Academy & Mr T Purslow 2020.  All images copyright free / creative commons unless otherwise stated. You are welcome to use under a Creative Commons Attribution-nonCommercial-ShareAlike License.
Back to content