Problem with shooting in direction of an object
Hey there,
I have a player controlled character (an active object) that can shoot a bullet in the direction it is facing (either left or right) when a key is pressed. For some weird reason I can't figure out, there are instances when the bullet is shot in a downward-like direction. This occurs when pressing the key after the player does one of the following:
When the player jumps straight into the air and lands.
When the player has not moved when the frame begins.
This also happens when jumping either left or right, and pressing the key rapidly when in the air.
I don't want this to happen, and I can't seem to find a fix. I'm assuming this is a common issue but I can't seem to find anything, so I'm sorry if this issue has been adressed elsewhere.
Thanks for the help! :)
Re: Problem with shooting in direction of an object
This is because the player character is actually facing downwards due to the direction he just moved.
There are various fixes, from setting/clearing a flag when left/right are pressed and shooting left/right based on whether that flag is set or not, to using a custom movement which properly decouples movement direction from facing direction.