Drag the CheckPoint scene into the Level 1 Scene
Drag the CheckPoint scene into the Level 1 Scene
Place the CheckPoint wherever you like.
Place the CheckPoint wherever you like.
Return to the Player Script
Return to the Player Script
Add a variable to keep track of the number of strawberries in the level
Add a variable to keep track of the number of strawberries in the level
Add another variable to track how many strawberries the player has collected.
Add another variable to track how many strawberries the player has collected.
The flag should trigger
The flag should trigger
if the player has collected all the strawberries
if the player has collected all the strawberries
Add a general Node to the level scene
Add a general Node to the level scene
Group all of the strawberries under this
Group all of the strawberries under this
This allows a quick way of counting all the instances of strawberries!
This allows a quick way of counting all the instances of strawberries!
In the Player Script
In the Player Script
Add a reference to this node, then code the ready function
Add a reference to this node, then code the ready function
In order emit the trigger signal in the CheckPointÂ
In order emit the trigger signal in the CheckPointÂ
FROM the player.
FROM the player.
We must add the CheckPoint to a group called
We must add the CheckPoint to a group called
checkpoint.
checkpoint.
Return to the CheckPoint Scene
Return to the CheckPoint Scene
Select the CheckPoint node
Select the CheckPoint node
Create a new group called checkpoint and add it.
Create a new group called checkpoint and add it.
In the Player Script
In the Player Script
Add a new function called complete_level
Add a new function called complete_level
If the player has collected all the strawberries
If the player has collected all the strawberries
get a reference to the checkpoint node
get a reference to the checkpoint node
emit the trigger signal
emit the trigger signal
reset strawberry count to 0
reset strawberry count to 0
Remember to call the function in process
Remember to call the function in process