Achieving oldschool platformer physics

Started by
7 comments, last by raigan 11 years, 8 months ago
I am using Box2D, with a world made by arbitrary polygons, and I can't get for the life of me the oldschool platformer feeling.

I am talking about moving at a constant velocity when you press the left/right keys, moving up/down on slopes at exactly the same way as on horizontal surfaces, and simple jumps.

I tried playing with friction, gravity, using impulses or setting velocity directly.

The issue is, no matter what I do, something works physically correct, which isn't really what I want.

If friction is set to 0, and the velocity is set directly (if left is pressed, move left, if right is pressed, move right, if neither is pressed, set to 0), the player moves correctly on horizontal surfaces, but would slip on curves for some reason, jump when stopping to move upwards (still there is still velocity in the Y axis), and jump sideways when starting to move downwards, still gravity doesn't catch up immediately.

If friction is set to 1, and the velocity is set directly (as above), the player doesn't slip from slopes, but still jumps upwards and sideways when stopping to move while going upwards or starting to move while going downwards respectively.
In addition, the payer gets stuck while going against a wall to his sides, but that can be solved by checking if he is in the air or not.

If friction is set to something very high, and I use very large impulses instead, while controlling manually the maximum velocity that the player can get to, then the player can't go up slopes (even the tiniest one) - he just gets stuck in place, and he also moves very fast when in the air (but this, again, can be controlled by checking if the player is in the air or not).

Is there a decent way to get the feeling of old platformers, or is Box2D not suitable for this?

Thanks.
Advertisement
I set friction to zero and just directly adjusted the velocity, still having it take a short but non-zero time to get up to speed makes it less buggy.

I never got slopes to work well, try setting friction to zero while moving and one or greater when the player isn't touching the move keys.
Essentially what you're asking is: How do you make a game act as though it doesn't use a physics engine.

Easy. Don't use a physics engine. Adjust the velocity/position of the objects directly, don't factor in acceleration or mass or friction or any of the other physics related parameters.
[size="2"]Currently working on an open world survival RPG - For info check out my Development blog:[size="2"] ByteWrangler

Essentially what you're asking is: How do you make a game act as though it doesn't use a physics engine.

Easy. Don't use a physics engine. Adjust the velocity/position of the objects directly, don't factor in acceleration or mass or friction or any of the other physics related parameters.


I realize that, but I really don't want to start handling collisions, so I am wondering if you can force Box2D to be less "physicy" :)

[quote name='Postie' timestamp='1343368861' post='4963528']
Essentially what you're asking is: How do you make a game act as though it doesn't use a physics engine.

Easy. Don't use a physics engine. Adjust the velocity/position of the objects directly, don't factor in acceleration or mass or friction or any of the other physics related parameters.


I realize that, but I really don't want to start handling collisions, so I am wondering if you can force Box2D to be less "physicy" smile.png
[/quote]

Fair enough, though it may be easier to write a simple sprite-based 2d collision detection system than trying to wrangle Box2D to work less like a proper physics engine.
[size="2"]Currently working on an open world survival RPG - For info check out my Development blog:[size="2"] ByteWrangler
I wrote a series of articles about making an old-school 2d platformer using modern techniques, including a physics engine:

http://www.wildbunny.co.uk/blog/2011/12/11/how-to-make-a-2d-platform-game-part-1/
http://www.wildbunny.co.uk/blog/2011/12/14/how-to-make-a-2d-platform-game-part-2-collision-detection/
http://www.wildbunny.co.uk/blog/2011/12/20/how-to-make-a-2d-platform-game-part-3-ladders-and-ai/

Hope they help!

Cheers, Paul.

I wrote a series of articles about making an old-school 2d platformer using modern techniques, including a physics engine:

http://www.wildbunny...rm-game-part-1/
http://www.wildbunny...sion-detection/
http://www.wildbunny...ladders-and-ai/

Hope they help!

Cheers, Paul.

These are very useful. +1'ed and bookmarked
Whilst looking for the exact same thing yourself, I came across Wildybunny's tutorials but find they didn't suit my needs because I wanted to have slopes that responded correctly.

What I ended implementing was something called SAT (Seperate axis theorem), which is probably half of what Box2D uses, just without accounting for friction, gravity, acceleration etc. for a full blown rigid body simulator.

If you want to have a crack at doing this, I used the tutorials on the following youtube video (description): [media]
[/media]

I actually think these are originally hosted on here somewhere, but this is where I found them. The only problem I can foresee of going down this route is that if you haven't got a grasp of the theory itself, trying to debug any thing, or expand upon the system for your needs will be hard if not impossible.

Edit: I don't know what language/framework you are using as I have never really looked properly at Box2D, I only know what it does. These tutorials were meant for C++, but I was able to implement it into C#/XNA without much trouble even though I have never learnt C++.
@Kasc: if you look through Wildbunny's other tutorials, you should find some really great ones covering collision detection and response for arbitrary convex shapes (including slopes): http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/

This topic is closed to new replies.

Advertisement