Godot Version
Godot v4.2
Question
To start, here’s the link to the player script:
And here’s a relevant screenshot.
I’m making a mobile game, but for the sake of fast development I’m using the mouse as the only input at the moment. I’m trying to implement it such that I can draw a line with the mouse, ( and if that line overlaps with that circle around the player (which is the attack range) then the player will attack in a direction parallel to the “attack line”.
I’m having some issues with this. I’d like to implement this with RayCast2D
, so I can easily check for collision, but for some reason it’s position and direction are not what they should be. The red line in the screenshot is a ‘test line’ I implemented with a Line2D
. The ‘anchor’ stays at the initial click position and the ‘head’ follows the mouse position, as it should. But the ray-cast, despite the values being reported as the same, does not look the same on screen. The anchor stays in the same place and the head moves when the mouse moves, but for some reason it’s not right on top of the Line2D like it should be.
I really don’t know what the issue is here. Debugging this is difficult. Any tips are appreciated, and let me know if any further info would be helpful.