Hey at the moment I'm creating a platforming game with box2d and I've run into some problems.
My character movement is implemented like (pseudo-code):
[/cut] I solved the first problem on my own 🙂
The second problem: when the character moves up a slope (a angled rectangle shape) and then suddenly stops, it wil jump up a little bit. I think the reason is that the character penetrates the slope when it moves, then shoots up to get out again when it stops.
Both of these behaviours are undesired in my game, is there anyway to stop those from happening? I'm also open for suggestions for other implementations for the movement system.
Thanks in advance.
ps: Sorry for my somewhat slacky english, hopefully I made myself clear.
My character movement is implemented like (pseudo-code):
Code:
void onUpdate()
{
if (rightButtonIsDown)
character->SetVelocity(b2Vec2(2.0f, 0.0f));
else if (leftButtonIsDown)
character->setVelocity(b2Vec2(-2.0f, 0.0f));
else
character->SetVelocity(b2Vec2(0.0f, character->GetVelocity().y));
}
void onUpPressed()
{
if (canJump == true)
character->ApplyImpulse(b2Vec2(0.0f, 10.0f));
}
(the character shape is a circle){
if (rightButtonIsDown)
character->SetVelocity(b2Vec2(2.0f, 0.0f));
else if (leftButtonIsDown)
character->setVelocity(b2Vec2(-2.0f, 0.0f));
else
character->SetVelocity(b2Vec2(0.0f, character->GetVelocity().y));
}
void onUpPressed()
{
if (canJump == true)
character->ApplyImpulse(b2Vec2(0.0f, 10.0f));
}
[/cut] I solved the first problem on my own 🙂
The second problem: when the character moves up a slope (a angled rectangle shape) and then suddenly stops, it wil jump up a little bit. I think the reason is that the character penetrates the slope when it moves, then shoots up to get out again when it stops.
Both of these behaviours are undesired in my game, is there anyway to stop those from happening? I'm also open for suggestions for other implementations for the movement system.
Thanks in advance.
ps: Sorry for my somewhat slacky english, hopefully I made myself clear.