Bouncy mushrooms can't bounce sideways
13 years ago
Well, as the title says. I'm implementing bouncy mushrooms as a simple Lua trigger. When Nippies enters the trigger, the Lua script reads his velocity, sets the y axis to a negative amount, and then sets Nip's velocity with that, sending him rocketing upwards.
However, late last night, when I was past the sleep-stage of being able to code, I tried to make a sideways mushroom. To my surprise, it didn't work.
I thought about it some.
My knowledge of my engine tells me that it's because simply setting his velocity on the x axis will be overridden as soon as the walk code runs, which is next frame after the jump, causing a jump-stop effect.
I already have several separate vectors which make up the velocity, such as your knock-back from enemies (reduced quadratically closer to [0, 0] every frame), jumping (ditto, but with a different curve based on the jump button) and conveyor velocity (constant set from the moving platform you're on, or [0,0]). I'll probably have to make another vector to be added in. Player::m_bounce, used for springs.
I'll add Lua functions Player.getBounceVelocity() and Player.setBounceVelocity() as well, so these triggers can set the bounce once. The engine will take care of curving it back to [0,0].
However, late last night, when I was past the sleep-stage of being able to code, I tried to make a sideways mushroom. To my surprise, it didn't work.
I thought about it some.
My knowledge of my engine tells me that it's because simply setting his velocity on the x axis will be overridden as soon as the walk code runs, which is next frame after the jump, causing a jump-stop effect.
I already have several separate vectors which make up the velocity, such as your knock-back from enemies (reduced quadratically closer to [0, 0] every frame), jumping (ditto, but with a different curve based on the jump button) and conveyor velocity (constant set from the moving platform you're on, or [0,0]). I'll probably have to make another vector to be added in. Player::m_bounce, used for springs.
I'll add Lua functions Player.getBounceVelocity() and Player.setBounceVelocity() as well, so these triggers can set the bounce once. The engine will take care of curving it back to [0,0].

RainChu
~rainchu
OP
Oh yeah it's necessary. All in a day's work :3