Rotating RayCast3D giving different results

Godot Version



I’m using a RayCast3D to determine the direction my character is pointing by using the to_global method on the RayCast3D’s target_position property. When I rotate the main CharacterBody node the target position changes like I expect but if I rotate the RayCast directly the target_position property never changes even though with the collision shapes debugger turned on I can see the RayCast is indeed rotating. Does anyone have any idea why the target_position is not changing?

did you do all these by script or just by editor using gizmos to rotate the nodes?
i tried by gizmos, it rotate as expected

Isn’t this because it’s target position isn’t changing because it’s the same position relative to its parent, and the parent is rotating?

I’m setting the rotation.y in code. It visually rotates but the target_position is not changing.

If I get the target_position directly it does return the local position but if I use the to_global function on the target_position I get the actual coordinates. I just did some more testing and when I rotate the character the target_position does update but if I rotate the raycast directly it does not update the target_position.

I created a little demo of the issue I’m talking about:

Godot Project Link