Issue with shooting in platform game!
Like the title implies, with my platform style characters, whenever I attempt to shoot while in midair, the bullets always drop straight down or occasionally up.
I have it set to: "Whenever 'Z' is pressed, shoot bullet at speed 75". Always looking in the direction of the character.
I assume its because when the character falls or jumps, the direction changes to suit. (i.e. falling=down, jumping=up)
Does anyone have any ideas of how I could keep the direction of the bullets purely forward and back? Or something I could change to make the issue easier on me?
Re: Issue with shooting in platform game!
Your guess as to the cause is right - when a character's moving more up/down than left/right, its movement is counted as those directions and not the direction that your character appears to face.
What I do to get around this is use a separate object, called "Facer" or something similar, that has only two animation directions - left and right - and is kept off the edge of the screen. I set up two events to make it face left when Left is pressed, right when Right is pressed, and then use its direction to choose the direction to shoot the player's bullets - click the "Use a calculation" button on the "Shoot in selected direction" option of the Shoot an Object dialog, and enter Dir("Facer").
Re: Issue with shooting in platform game!
Or you could use values. I just make a "direction" value for my player that is shooting.
User presses right- Set value to 1
User presses left - Set value to 2
Value is 1- Set direction to right
Value is 2- Set direction to left
And instead of shooting in direction of player, you could also use
If value is 1 and user shoots - Shoot bullet at 0
If value is 2 and user shoots - Shoot bullet at 16
Re: Issue with shooting in platform game!
Sweet! Thanks for the idea.
That's pretty clever, wish I had thought of it. =P
Anywho, I'll be sure to try it. I'll let you know how it goes.
EDIT: Heck yeah. All things looking good. Thanks for the quick replies you two.