** How do i make lots of checkpoints with one? **
I want the player to be able to “when in collision with checkpoint save”
but it dont work i tried it using the events sheet but it will keep spawning the player at the first checkpoint.t
plz help
plz help
Hi!
Here is the simple example of multiple checkpoints. You have the player character (stickman), ground (black), deadly slime (green) and checkpoints (blue), where the character spawns if it hits the deadly slime.
Now create the object variable “ID” to Checkpoint object, the initial value can be e.g. zero.
When you add checkpoint objects into your scene, remember to change the object variable to each of them; 1 to first one, 2 to second one etc.
By this way all the checkpoints have the unique identifier.
Then add the scene variable called “Checkpoint_Now”, which stores the information, which checkpoint is the latest the player has passed.
Now the code:
Why this works? The event where the player collides with the deadly slime, there is the second condition which identifies, which checkpoint object is the one where the player should be moved. Without that condition GDevelop is not able to know, which checkpoint you are meaning.
Hope this helps.
Thank you so much, It took me a while to understand how to do the variables but it works now.
Thanks alot.
Ok, the problem is in the line shown in the image below.
In your code you have ‘=’ when you should have ‘>’ .
What does that condition do? The idea is, that if the player has already passed e.g. checkpoint 5, and then the player goes backwards and collides with checkpoint 4, that condition prevents the code from saving checkpoint 4 as “Checkpoint_Now”. The Checpoint_Now variable is updated only, if the ID of the collided checkpoint is bigger than the ID saved in Checkpoint_Now variable.
The code works fine even without that condition. Without it the Checkpoint_Now varable is updated every time when the player collides some checkpoint object, even if the ID of the checkpoint is smaller than what is saved in Checkpoint_Now variable.
Thanks so much(again!) i was just about to say it was not working again when i saw that one of my checkpoints var was 0 the other one 1, so i changed 0 to 1 and 1 to 2 and then it worked once again ty so much i guess u can mark this solved.