I've tried searching for this thousands of times and never found a direct answer to it, no tutorials on YouTube at all (I did find some but none were English, and they didn't explain what they were doing and why).

I just want to create a checkpoint where when the player touches that checkpoint, if the player falls in the fallzone, or has 0 lives, then the player will go back to the checkpoint where the coins the player collected will be reset. The last part is optional to be honest as I'm challenging myself, but I'm not sure what to use for that. I did create a fallzone signal, so when the body "Player" enters the fallzone, then a print will happen "Player has fell into the fallzone", but now all I need to do is implement a checkpoint system.

I created "Position2D" node as in one of the tutorials I saw that.

Any ideas of how to do it?

func _on_Fallzone_body_entered(body): #When player touches the fallzone
	if (body.get_name() == "Player"): #Making sure that who fell is the player
			print("Player has fell into fallzone!")

Welcome to the forums @Tractic!

There are several different ways to handle checkpoints, but here is what I have found as the easiest way:

  • Have an Area2D node (with a CollisionShape2D) that covers where you want your checkpoint to be. Make sure to make it big enough that the player cannot easily avoid the collision shape if they walk by the checkpoint.

  • In the Area2D, connect the body_entered signal to a function. In this function, check to see if the body that has entered is the player. If it is, then add something like player.checkpoint_position = global_position.

  • In your player script, add var checkpoint_position = null to your class variables. This variable will store the position of the last passed checkpoint, and the checkpoint will set this position when the player has passed (as seen in the step above).

  • Then, when the player has entered the fall zone, move the player to the stored checkpoint_position variable IF it does not equal null. Something like:

    if (body.get_name() == “Player”): print(“Player has fell into fall zone!”) if (body.checkpoint_position != null): body.global_position = body.checkpoint_position

And that should do it! It is a super simple way of handling it, and I would suggest making some changes if you plan to use this method going forward (like making the respawning at a checkpoint a function of the player that the fall zone calls), but hopefully this helps give you a bit of an idea on one way that checkpoints can be achieved.

Also:


This discussion was caught in the moderation queue since you have not confirmed your account yet.

Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.

If you need any help, please let us know! You can find ways to contact forum staff on the Contact page. Thanks! :smile:

I appreciate the help. I will be trying it out very soon.

I'm still new to Godot, but I instantly liked it. One issue is that there aren't that many tutorials and much explanation about how to do some stuff including that checkpoint. It could just be myself not exploring enough in the docs, but thanks anyways.

2 years later