• 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!

SOLVED trouble with image_angle

F

FiftyFive

Guest
(i m not good at english sry :D)Hello i am new in gm2. I am having trouble with "image_angle" command --> Like in the photo i want to add 2 barrier(invisiable) for gun when mouse is too high or low i want to stop the gun following the mouse
 

Attachments

Nocturne

Friendly Tyrant
Forum Staff
Admin
Hello! You want to clamp the image angle to specific values. The easiest way to do this is to simply do:
GML:
var _d = point_direction(x, y, mouse_x, mouse_y);
if _d > 45 _d = 45;
if _d < 315 _d = 315;
image_angle = _d;
That will work when the instance is facing RIGHT only though. If you want it to clamp when facing left or right then you'll need to modify that code somewhat... :)
 
Top