hugomiguel046
Member
Hello, guys!
So, I made an object Crosshair that follows the mouse while staying in a circle around the player, using this code:
The problem is: the mouse itself can still get out of the circle. So, if it's outside the circle and I want to move the crosshair, I have to move the mouse all the way to the circle and then I can move the crosshair. Locking the mouse to the circle would solve it, but it's being really hard to do it, and all the similar questions I found are not helping me.
Any ideas or better solutions ?
So, I made an object Crosshair that follows the mouse while staying in a circle around the player, using this code:
GML:
var dist = min(300, point_distance(obj_player.x, obj_player.y, mouse_x, mouse_y))
var dir = point_direction(obj_player.x, obj_player.y, mouse_x, mouse_y)
x = obj_player.x + lengthdir_x(dist, dir)
y = obj_player.y + lengthdir_y(dist, dir)
The problem is: the mouse itself can still get out of the circle. So, if it's outside the circle and I want to move the crosshair, I have to move the mouse all the way to the circle and then I can move the crosshair. Locking the mouse to the circle would solve it, but it's being really hard to do it, and all the similar questions I found are not helping me.
Any ideas or better solutions ?