I have a left/right side scroller game. The actor moves left/right and collides/interacts with other box2d fixtures.
I am moving the actor using:
every time step.
Now when I go to jump (jump button touched) I do:
again every time step.
If actor is in midair (i.e. no contacts registered on feet) then I have to "push" actor back down using:
If any contacts register on actors feet then I do:
I assumed this was the best way to handle jumps but obviously not.
The actor jitters when near the ground. I assume it's because of small simulation errors (or maybe something else).
I log when a contact is made with actors feet and the ground and see a log of back and forth "contact"/"no contact"
Anyone have a better scheme to do actor jumping or know how to fix this issue?
I am moving the actor using:
Code:
actorBody->SetLinearVelocity(VelXdir,0)
every time step.
Now when I go to jump (jump button touched) I do:
Code:
actorBody->SetLinearVelocity(VelXdir,+20)
again every time step.
If actor is in midair (i.e. no contacts registered on feet) then I have to "push" actor back down using:
Code:
SetLinearVelocity(VelXdir,-10)
If any contacts register on actors feet then I do:
Code:
actorBody->SetLinearVelocity(VelXdir,0)
I assumed this was the best way to handle jumps but obviously not.
The actor jitters when near the ground. I assume it's because of small simulation errors (or maybe something else).
I log when a contact is made with actors feet and the ground and see a log of back and forth "contact"/"no contact"
Anyone have a better scheme to do actor jumping or know how to fix this issue?