Page 1 of 1

Typical Platformer Physics

Posted: Mon Mar 23, 2009 5:25 pm
by Matkins
Hello,

I've come to LOVE through wanting to create some little games and so far I am enjoying the engine. I'm creating a platformer and want to know how I can use box2D for gravity and jumping but to have no friction or rotational velocity when trying to move the character sideways as he walks. The problems I have encountered when trying to use a rectangle body shape for my character's bounding box is that it has friction with the ground and falls over if i try to apply a sideways force. What is the best way to move my character along the floor? The best solution I've come up with so far is to use a circular body shape, but that will mean: a) the bounding box is the wrong shape, and b) if he's ever stood on a sloping floor he will roll down it.

Any hints you can give me will be very welcome,
Thankyou.

Re: Typical Platformer Physics

Posted: Mon Mar 23, 2009 9:39 pm
by Alex
My solution: set the friction of the character to 0 and create a custom friction function. If you find that too complicated, you could also try setting the character's centre of gravity lower to the ground. I've had decent results with a combination of the two. In the end it all depends on what kind of range of motion you want your character to have.

Re: Typical Platformer Physics

Posted: Thu Mar 26, 2009 8:53 pm
by machee
Probably the best solution would be Box2D's Body.FixedRotation flag, which is not yet implemented in LOVE.

http://www.box2d.org/wiki/index.php?title=B2BodyDef

Until then, I'm not sure either. Setting the Player's Body's Angle to 0 every update sorta works, but has some over lap issues. ( body:setAngle(0) )

http://love2d.org/forum/viewtopic.php?f=4&t=381

Re: Typical Platformer Physics

Posted: Tue Apr 07, 2009 10:43 pm
by AirPump
I, personally, would prefer to do custom-programmed physics. They're not too hard in ordinary platformers, and physics engines may or may not be a bit iffy.