Godot Version
4
Question
Hello! I am having an issue with updating my player’s global position. I am making a respawn function for when the player makes contact with the respawn collision (named Oob_Respawn). I made a print to check if the collision works, and it does. The issue is when I add the line to update the global position.
Using player.global_position = Vector2(500, 500) makes it so the player respawns at a random spot, and it looks like it only spawns for a quick second.
I am adding a screenshot of the main scene and another of the player’s tree.
The RigidBody2D moves on it’s own, the Player Node is only a parent of the RigidBody, so it may never move itself. RigidBody also does not like to have it’s position updated outside of specific physics functions. YOu should probably use a CharacterBody2D for your player unless you know what you are doing with RigidBodies
Expanding on what @gertkeno said here, physics-related nodes needs to be used in a certain way. You should not move RigidBody3D indirectly (e.g. via moving its parent) because the physical state is not inherently linked to the node transform.
To fix your issue, I would recommend changing the root Player node into a RigidBody3D instead and then do the appropriate adjustments in the scene tree. It should work after making this adjustment.
Let us know if you have any questions.
This worked! It was very simple to change the node type. I had to make some adjustments with a pin joint but its all good now. Thank you both : )