Raycast 2D is getting only half way to the player

Godot Version

4.3

Question

` Heyo! I tried to make enemies shoot when they see the character by using raycast2D. Everything in code looks fine, but instead of going to player position, ray stops half way there. This is the code i used:

ā€œ$aimray.target_position = to_local(player.position)ā€

Does anybody have any idea why that could be? `

try the global_position:

$aimray.target_position = to_local(player.global_position)
1 Like

I tried it and it used to shoot the ray out far off the screen in the oposite direction. I sat on it for 6 hours but i managed to repair that. I just deleted it and added new one andit works even tho nothing changed. But thanks for help :stuck_out_tongue: