Point on the line (vector)

G

greebdork

Guest
So, it seems i'm dense as an oak, i can't figure out how to make an object always stay on the line between other object and a mouse position, and at constant distance from said object.
Let's say i have a obj_player with x and y, mouse_x and mouse_y, and i want an obj_reticule stay at the 10 pixels from obj_player and on the line between mouse position and player position, so it would orbit the player depending on the relative position of the mouse to the player. I hope it makes sense.
 
I

icuurd12b42

Guest
var a = point_direction(obj_player.x,obj_player.y,mouse_x,mouse_y);
x = obj_player.x+lengthdir_x(10,a);
y = obj_player.y+lengthdir_y(10,a);
 
G

greebdork

Guest
var a = point_direction(obj_player.x,obj_player.y,mouse_x,mouse_y);
x = obj_player.x+lengthdir_x(10,a);
y = obj_player.y+lengthdir_y(10,a);
Thanks a bunch, as it's always with me everything boils down to not knowing proper functions, i should really read that reference manual through.
 
I

icuurd12b42

Guest
it only take 2 hours to skim read the help file. 30 minutes to just look at the function names
 
I

icuurd12b42

Guest
I benefit more to answering questions than you do asking. it makes me own my skills while you disown yours :)
 
Top