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

GameMaker Help having the player smoothly holster weapon - 2d sidescroll

B

BeansMyth

Guest
Hi, i have searched everywhere for insight about this, but I'm lost.

Here is what I want:

The player should be able to take their gun out with a certain key and aim it around.

I think i would need to change the sprite then to an armless version and then draw on some move-able arms so they can aim. And then they would put the gun away, and I would undraw the external arms and set the sprite index back to the armed ones.

Is this the...good way of doing it? The style I'm going for is sort of a non-pixel and smooth animation look. I don't want arms just disappearing if the player stops aiming.

Not sure if I explained my idea in the best way, but i feel like theres probably a better way to do it. My project doesnt have more than maybe three weapons, one being melee.
 

curato

Member
best way is to have separate sprites and layer them works especially well in a top down view. You just have to mash them together in the draw even then you can change out which arm sprite to use pretty easy.
 

NeoShade

Member
The way you've descibed your idea, you would end up with three sprites:
  • character_with_arms
  • character_without_arms
  • arms
With this system, whenever the character draws or holsters their weapon, you need to do two things:
  • change the base character sprite to/from the armless version
  • begin drawing a second sprite containing only arms



An alternative (but similar method) would be to have these three sprites:
  • character_without_arms
  • arms_with_weapon
  • arms_without_weapon
Now, whenever your character draws or holsters their weapon, do the following:
  • change which arms sprite is being drawn
Because you're always going to be drawing two sprites instead of one, there might be a small performance hit, but it would be very minimal.



With either method, there are pros and cons. I just thought it might be worth mentioning this alternative.
 
Top