1 decade ago by quidmonkey
So I'm developing a platformer using Box2d, and I'm having some trouble with the jumping.
My player.update() is simple:
I'm setting this.standing based on this thread.
What's odd is that sometimes he'll jump at the proper height, while other times he'll barely get off the ground. Why is this so inconsistent?
My player.update() is simple:
// move left or right if( ig.input.state('left') ) { this.body.ApplyForce( new b2.Vec2( -this.speed, 0 ), this.body.GetWorldCenter() ); this.flip = true; } else if( ig.input.state('right') ) { this.body.ApplyForce( new b2.Vec2( this.speed, 0 ), this.body.GetWorldCenter() ); this.flip = false; } //jump if( ig.input.pressed('hops') ){ if( this.standing ){ this.body.ApplyForce( new b2.Vec2( 0, -this.jumpSpeed ), this.body.GetWorldCenter() ); } }
I'm setting this.standing based on this thread.
What's odd is that sometimes he'll jump at the proper height, while other times he'll barely get off the ground. Why is this so inconsistent?