• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Make a laser head towards a player

B

Bokkie2988

Guest
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