Hi, I am making a game and for some reason, when my character lands, instead of stopping immediately when he hits the ground, he goes up and down 2 or 3 times (helps to slow the fps down low to see it). I can’t for the life of me figure out why this keeps happening, instead of just stopping when he hits the platform.
Heres my falling code:
onClipEvent(enterFrame) {
platform = _level0.stage.platform; // the platform he lands on
// Y Movement //
this._y += GokuFallSpeed;
if (!platform.hitTest(this._x,this._y + GokuFallSpeed,true)){ // If Goku is not on a platform
if (GokuFallSpeed < fallSpeedLimit) {
GokuFalling = true;
GokuFallSpeed += _level0.gravity;
}
}
if (platform.hitTest(this._x,this._y + GokuFallSpeed,true)){ // If Goku is on a platform
if (GokuFallSpeed >= 0) {
GokuFalling = false;
GokuFallSpeed = 0;
}
}
}
So I am using hitTest to determine where he should stop falling.
I attached the game file.