# How would I make a bullet shoot from my player to my mouse.

So far I've created an object called obj_mouse. And my plan is whenever the player left clicks, it spawns a bullet from him toward where ever the mouse is pointing. I've got the concept down, but I'm struggling getting it to work.

Extra bits of code I'm messing around with to try and get it to work:

    bullet=instance_create(x,y,obj_bullet)
with (bullet) {
move_towards_point(mouse_x,mouse_y,5)
image_angle=direction
}

point_direction(obj_mouse,obj_mouse,obj_mouse,obj_mouse)
image_angle=direction


(In the above code, I havent attempted to specify to the program that I want the bullet to go in the direction of obj_mouse, or rather, just the mouse. The above code works, and bullets do shoot, however the player must have the mouse on the players sprite for it to work.)

You need to use Global Mouse events.

point_direction(obj_mouse,obj_mouse,obj_mouse,obj_mouse)


is very strange. You need store result, and you need use coords (not objects names)

direction = point_direction(x, y, obj_mouse.x, obj_mouse.y);


just for example

Step End event:

direction = point_deirection(x, y, mouse_x, mouse_y);
image_angle = direction;


Mouse Global Left Pressed event:

with (instance_create(x, y, obj_bullet))
{
direction = other.direction;
image_angle = direction;
speed = 5;
}