Dealing with collision events
Now that we have a collision mask, we can have our kart respond differently, depending on where it is driving. When on the road, the kart will increase throttle up to full speed. When hitting the sandbox it will be slowed down, and hitting the walls is even worse. The kart will bounce back and completely lose momentum.
Let's build these responses with a few scripts.
Engage thrusters
We will add a series of script instructions to the player1
sprite. We will assemble the instructions first, then place the script segment at the right spot in the existing script:
Start with an if () then block.
For the condition, we will check touching color ()?.
Click on the color box and then on the sandy color of your collision mask with the eyedropper icon.
Inside the if () then block, place a set <speed1> to () block.
When the kart drives through sand, we will slow it down. We do this by multiplying its current speed with a number smaller than 1
using these following steps:
Place...