How to move path x and y to mouse x and y?

  • Thread starter Deleted member 16767
  • Start date
D

Deleted member 16767

Guest
So I have a circle with straight lines as the connection kind. I want to move this when I press CTRL + SHIFT and it must move to the direction where I am pointing at with my mouse. How do I do this in an easy way? What I mean is I don't want the path pre-assigned to the place I have drawn it on in the path editor, I want to manually move all connections to a desired place, which is, the mouse pointer.
 

TheouAegis

Member
path_shift() will move the path by a specified amount (not to specified coordinates) using point 0 as the reference. If your path is closed and you want the "middle" to move to the mouse, you will need to find the x and y offsets from point 0 to the ml"middle".

Note this affects the path resource itself. I think GM duplicates the path data, or used to, because you will need to stop and restart the path to have it take effect for an instance.
 

Padouk

Member
Have a look at the path and motion planning api
Depending if you want to avoid obstacle or move in straight line you will want to create and assign a path to your object

GML:
var path_id = path_add();
path_add(path, x, y);
path_add(path, mouse_x, mouse_y);
path_set_closed(index, true);
path_start(path, 3, path_action_stop , true);

GML:
var path_id = path_add();
mp_potential_path(path, mouse_x, mouse_y, 3, 4, 0);
path_start(path, 3, path_action_stop , true);
 
Top