Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Martogh |
Hi,
I’ve been doing Godot for a little while now. I have come across a problem and have no clue how to solve it. I need to make a spawn point that sends you back to an old scene when you die. E.G You save in scene 1 go to scene 2 and it sends you back to scene 1’s respawn point.
(Im saving the SavePos and SaveScene in an Autoloaded script)
For the respawn point i have:
func _on_Area2D_body_shape_entered(body_id: int, body: Node, body_shape: int, area_shape: int) -> void:
if body.name == "Player":
Global.SavePos = position
Global.SaveScene = get_tree().get_current_scene()
used = true
For in the root nodes script i have:
func _on_Stalactite_hurt_enemy() -> void:
get_tree().change_scene(Global.SaveScene)
$Player.position = Global.SavePos
This script saves the current scene and the position in a Autoload script and then when you walk into the Stalactite you get sent back to the scene and the position. When this happens though you get sent to a blank scene with nothing there.
Something i found is that when you remove the change_scene you get sent to the right position its just the scene that’s not working.
If you need the scene tree just ask, i don’t know if its relevant or not and honestly can’t be bothered adding it rn.
Thankyou for any help you can give me.