Typical Platformer Physics

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Matkins
Citizen
Posts: 53
Joined: Mon Mar 23, 2009 5:12 pm

Typical Platformer Physics

Post 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.
Alex
Prole
Posts: 30
Joined: Mon Mar 09, 2009 1:49 pm

Re: Typical Platformer Physics

Post 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.
machee
Prole
Posts: 5
Joined: Tue Mar 03, 2009 12:35 am

Re: Typical Platformer Physics

Post 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
AirPump
Prole
Posts: 12
Joined: Tue Mar 24, 2009 7:55 pm

Re: Typical Platformer Physics

Post 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.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 6 guests