S
Strakee
Guest
Hi, so I've been trying to make an object_view be in the half of the distance between my object player and the nearest enemy so I can have more dynamic views. If solved I will do a max distance but that I can figure out myself.
Here's my code and it just simply doesn't work as intended on paper. I want it to get the distance between those two objects and the direction and set it's location on the exact half between them.
p=obj_player
k=obj_enemy_parent
var ex, ey;
ex = instance_nearest(x, y, k).x;
ey = instance_nearest(x, y, k).y;
len= point_distance(p.x,p.y,ex,ey)
dir= point_direction(p.x,p.y,ex,ey)
xx= lengthdir_x(len,dir )
yy= lengthdir_y(len,dir)
move_towards_point(xx/2,yy/2,2)
This is in the end step event of the view object by the way.
Here's my code and it just simply doesn't work as intended on paper. I want it to get the distance between those two objects and the direction and set it's location on the exact half between them.
p=obj_player
k=obj_enemy_parent
var ex, ey;
ex = instance_nearest(x, y, k).x;
ey = instance_nearest(x, y, k).y;
len= point_distance(p.x,p.y,ex,ey)
dir= point_direction(p.x,p.y,ex,ey)
xx= lengthdir_x(len,dir )
yy= lengthdir_y(len,dir)
move_towards_point(xx/2,yy/2,2)
This is in the end step event of the view object by the way.