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

Legacy GM Top Down Recoil

Gamerev147

Member
Hello! I have a few questions about a recoil system that I want to implement.

Here is a diagram of what I want to happen. More explanation and code is written below the diagram.



Ok so when the player fires, i want the sprite to either snap a few pixels right, left, up, or down depending on the direction that the player is facing at that current moment.

Here is the code I'm using for controlling where the player is facing (at the mouse):

Code:
//Smooth Rotation in Step Event
dir = point_direction(x, y, mouse_x, mouse_y);
image_angle += sin(degtorad(dir - image_angle)) * rspeed;
rspeed = 16; //in the create event

So how can I implement this type of recoil? Any ideas?
Thanks!
 
P

PandaPenguin

Guest
quickest way might be to add a little friction to the player object when you fire and add a little motion to it into the opposite direction of your aiming

without the friction the player object would continue the motion infinite but with friction it will come to a halt depending on the strength speed of the motion and the amount of friction you add
 
P

PandaPenguin

Guest
image_angle = point_direction(...)
image_angle+=random_range(-recoil,recoil);
oh well maybe I have a different understanding of "recoil" :D

so are you looking for bullet spread...or recoil?
 

Gamerev147

Member
oh well maybe I have a different understanding of "recoil" :D

so are you looking for bullet spread...or recoil?
I have bullet spread. I just want to put some "feel" into firing. It feels like you aren't firing in my game.
I got something similar to what I wanted.

Thank you guys so much! :)
 
Top