Godot Version
4.2.2
Question
Hello all, had a quick crisis earlier today when I thought that I was doing my raycasts all wrong, but then figured out something odd that I must be missing.
When making a raycast in gdscript, I used this:
var query = PhysicsRayQueryParameters2D.create(los_raycast.global_position, tethered_object.base_collision.global_position,
0b00000000_00000000_00000000_00000011, [anchor])
It shoots a raycast from the base of player to the object that they are tethering to. I know it works, I’ve tested it and if something in the correct layer gets in the way, the tether breaks.
I was working on another addition, and was wanting to better visualize the raycasts that I was using, so I wanted to use the draw_line, and pass in the same variables, but it places the lines in different spots.
The code for the lines was:
draw_line(los_raycast.global_position, tethered_object.global_position, Color.YELLOW, 1.0)
It seems the beginning point of the line is twice the distance from the world center to the beginning point, and then the end point is the distance and angle from the world center to the end point, not the distance from the beginning point to the end point.
This also happens if I instantiate an object at “self.global_position”, it will appear at twice the distance from the world center to the player.
Howcome this happens with draw_line and instantiating objects, but not with raycasts? Is there just an option I am missing, or am I fundamentally misunderstanding global_position?