0 votes

I am currently working on a 3d jump and run game. When the player enters an area he should respawn. I did this by restarting the scene but the music restarted, too. I want the music to play constantly in the background, even after the player dies. Instead of restarting the scene, I tried to teleport the player back to the beginning of the level, but i could find nothing about teleporting players in 3d in the internet.

How can I teleport a KinematicBody in 3d space?

asked Feb 10 in Engine by Me (25 points)

1 Answer

0 votes
Best answer

No need to restart the scene, that is similar to using get_tree().reload_current_scene() which will literally really restart the whole thing, you can "restart" the scene by using your own methods.
To teleport a player to a target position, you can simply change the node's "position" property.
If you have different levels that are different scenes, which means that just changing the position won't work, you need to have methods like level_start(level), level_finished(level), go_to_level(level), or something like that to keep things organized.
When player dies, if you want it to go back to the beginning of the level, use method level_start(), or whatever your method's name is.
If you want to go to a different level, call go_to_level().
So, if you didn't create some methods or similar methods, go and add them. When the game start, use level_start(1) instead of functions like _read()

answered Feb 10 by Sween123 (726 points)
selected Feb 10 by Me
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.