Gw Temp


Tutorial - 'Mousing Aiming, And Basic AI' by Guest

An item about Gamemaker posted on


Need to know how to use that mouse to aim in Game Maker? Read up, son!


Requirements:Variable knowledge/some GML
Ok,first off,the aiming with mouse.Make the sprite of a crosshair or whatever.make sure to set the origin to the middle(You need to be in advanced mode)now,make a new object.Have it be the sprite for the crosshair you made.Now,in the step event,put this.
So it should be at the mouse.Go under game options now.Set it so the mouse isnt displayed.Now,make a bullet.In the create event for the object,put this.
Now,it's all set.except for one thing.Make a new object.Now,make a global mouse pressed it,put this.
and voila!
Ok,this is simple.put this in the stpe event for the object.
if distance_to_object(player)<200 {move_towards_point(player.x,player.y,8)}
Easy.Now,if you want it to chase and fire bullets...
make an enemy bullet object.put this in the create event for it.
and in the collision event,have it do damage then destroy,in the actual enemy,set variable shoot to 1 in the create,put this in the stpe event.
if distance_to_object(player)<200 {move_towards_point(player.x,player.y,8) if shoot = 1 {instance_create(x+0,y+0,enemybullet) shoot = 0 alarm[0] = 3}}
now,in the alarm 0 event,set shoot to one.and there you have it,aiming with mouse and some basic AI.
Please tell me of any bugs,