Topic was automatically imported from the old Question2Answer platform.
Asked By
leftstickgame
okay i have a 2d platformer vary simple it got a moving character and a tile map but i don’t know how to re-spawn a character i am vary new and was hopping someone would help with this
also it would be vary helpful of nodes I need to do this
i’m using a a kin character
Respawning depends on what you really want in detail.
Here are the approaches I know:
Just reposition the player at the beginning (spawn point or whatever) by remembering its initial state in its script. I do this in my game for all dynamic objects because it’s faster than reloading the entire level, however it can be harder to implement if there are many dynamic objects. I put all respawnable objects into a group, and then do get_tree().call_group to call a function I made on all of them to execute their specific respawn logic.
Reload the entire scene. It’s the opposite of 1), so all states will be reset. Any state to “remember” will need to be stored outside the scene (in an autoload singleton for example) and reapplied after the scene is reloaded, if needed. It is the simplest way if you just want to “forget and restart” the game. To do this, you can use get_tree().reload_current_scene().