Make a laser head towards a player

Bokkie2988

Member
Hello,

So I'm making a space game where spaceships will shoot lasers towards a player.
I want that once the laser gets created, it automatically heads towards the player, but not exactly. That way the player can still dodge the laser.

Can anyone help me with this?

-Bokkie
 

Jakylgamer

Member
look in the help file for point_direction
and give it a random direction when its created
Example:
Code:
var inst = instance_create_depth(x,y,0,obj_laser)
inst.direction = point_direction(x,y,obj_player.x,obj_player.y)+random_range(-20,20); //random_range() will act like an accuracy so its not perfectly aligned with the player upon creation
inst.speed = 8;
 
Top