Collect the coins
Lesson 4 of 16 · GDev.Micro
A collision condition is true when two objects overlap. Player is in collision with Coin is how almost every pickup in a 2D game begins.
There are five coins, and each one is an instance of the Coin object. The collision condition picks only the instances touching the Player, so Delete Coin removes that coin and leaves the others alone.
A variable stores a value that changes during play. Add 1 to the scene variable Score each time a coin is picked up.
Object picking is the quiet superpower of GDevelop events: the actions of an event apply only to the instances its conditions selected.
When Player touches a Coin, delete that coin and add 1 to Score. Watch Score in the debugger.
Do it in the browser: a real game design tool, a short mission and instant feedback. No install.
Start this lesson — free