I'm working on a top-down perspective game in which the standard movement is via the 8Direction (8Dir) behavior. Upon pressing the specified "dash button" on the keyboard, the character should briefly dash ahead using the Bullet behavior and then return back to normal movement.
The Set-Up
Dash button pressed
- Stop all momentum from the 8Dir behavior (I found that the momentum was "held over" after re-enabling the behavior when the dash was finished)
- Enable Bullet behavior and set the Bullet angle of motion to the facing angle of the character
- Set Bullet speed to 500 because the Bullet behavior deceleration value is -800 (I didn't want a future use of the Bullet behavior to be at 0)
- Start a self-countdown timer for how long the dash should last
- Disable 8Dir behavior for the duration of the dash
When the character timer is up
- Re-enable 8Dir behavior
- Set the 8Dir speed to whatever the remaining value of the Bullet behavior speed was (remember, it had a -800 deceleration)
- Disable the Bullet behavior
What I'm TRYING to Accomplish
- Activating the dash should send the character rushing ahead at its given angle.
- After a 1/4 second, the movement behaviors switch back to normal and the angle of the Bullet motion is set as the character's angle.
Problem
When resuming normal 8Dir movement, there is an immediate sudden right "burst" of movement after the Bullet behavior is de-activated.
I have discovered what I believe the issue to be. Upon re-activating 8Dir, 8Dir's angle of motion value is 0, hence the sudden movement to the right. There are no actions for the behavior to edit this value. I can set the object's angle and its Bullet angle of motion...but not its 8Dir angle of motion.
https://www.dropbox.com/s/vltqn912290myl5/Sir%20Slash.c3p?dl=1
I'd appreciate any input on how to resolve this. Thank you!