Step 4: Tagging the obstacles and making them immovable
Nope! They just fly away. We need to add a script to them, so right-click on one of the spike objects, and add a new script.
We're going to tell the obstacle to become immovable (so it doesn't fly off when hit), and also to give itself a tag. A tag is like a name tag which allows other game objects to identify the tagged object. Grab the "When created" block from Events, and then grab "set immovable" block from Physics, and drag it in the first block.
We could disable physics on the obstacles to prevent them from flying away, but if we disable physics then we can't detect collisions. We must detect collisions between the character and obstacle to be able to make the character crash.
The next block to grab is "add tag name on myself" from Sensing. Drag this block underneath the "set immovable" block. Click on tag name, to edit it, and change it to killer. Now the character will know that all obstacles have this tag, and it can check for it.
Click Level Editor to save this obstacle script and return to editing your level. Make sure you apply this script to all obstacles in your game. To do this, click on the obstacle script from the scripts sidebar, then click on all obstacles to apply the script (make sure you have the right layer selected).