Hey! In my game, there is a spike that kills and deletes the player node. But since the camera is a child, I need to orphan the camera before the player dies so the player can see their death. It seems like a simple question, but I’ve looked at the documentation, looked at tutorials, and asked ChatGPT, but I found nothing. I’ve debugged the code and the code does work, but I just need the line. If I could get help, that would be great, and thanks in advance!
I would use @gertkeno s solution as well in most cases. But in case you actually want to reuse the camera, I’d consider these steps:
choose a new parent node, new_parent for the camera (e.g. the level, a different player,…)
call camera.reparent(new_parent, true). Having the second argument set to true means that the camera keeps it current position
if you want to switch to a different camera camera2 you can call camera2.make_current()
This does not really orphan the camera (it is still part of the scene tree), but if you make a different camera the current one, the previous camera is not in use anymore.
Instead camera in player node you can have RemoteTransform with camera in Remote Path(not child of player), now you can kill player and camera will be untouched