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

GML What is the best way to model recoil climb in in my platformer?

T

Triangle

Guest
Alright, I'm in the very very early stages of working on a platformer with mouse aim. It uses the standard kind of system where a separate arm object rotates around the player's shoulder with an image angle that follows the cursor. For a handful of design reasons, I really don't want to use an alternative method like excessive bloom / spread for the bullets instead of conventional recoil - besides, I'm handling that sort of thing with another system as well, so I want to keep recoil separate. I figured the straightforward thing would be to 'push' the cursor upwards a few pixels every shot. So now my question is: how exactly do I do that, and is there a better way?

I know that I can pull the mouse position with some constants, but can I use those to alter the mouse position?

Would I be better off spoofing the cursor with an object that follows the cursor at all times besides when recoil is happening and then writing the arm object's trigonometry code to target that instead of the cursor?

And finally, if altering the mouse position directly is the best way, what can I do to avoid issues where the player loses control of the mouse in menus / windowed mode / e.t.c? I understand it's generally discouraged to directly mess with the cursor, so I might as well do it right.

Thanks for any advice y'all have for planning this out.
 
T

Triangle

Guest
Thanks, that's helpful.

(Edit): Anyone else reading this thread, I'm still happy to hear other ways of doing this. Thanks arish for pointing me in the right direction!
 
T

Triangle

Guest
Thank you very much arirish, it works like a charm! I'll post all the code I ended up using to add my recoil climb in case anyone stumbles across this thread with a similar problem.

Put the below code in the gun's step event
Code:
// Check the mouse postion
MouseXCord = window_mouse_get_x();
MouseYCord = window_mouse_get_y();
Then put this code in the firing portion of the code so it runs whenever you shoot
Code:
// Nudge the mouse with REALrecoil
    window_mouse_set(MouseXCord, (MouseYCord - 4));
For some reason mouse_x and mouse_y didn't work for me, so I used window_mouse_get_x/y for that.
 
Top