Sign in to follow this  

Achieving oldschool platformer physics

This topic is 1958 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. Edited by wolfscaptain

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[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.
[/quote]

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" :)

Share this post


Link to post
Share on other sites
[quote name='wolfscaptain' timestamp='1343369796' post='4963533']
[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.
[/quote]

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" [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
[/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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[quote name='wildbunny' timestamp='1343475051' post='4963914']
I wrote a series of articles about making an old-school 2d platformer using modern techniques, including a physics engine:

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

Hope they help!

Cheers, Paul.
[/quote]
These are very useful. +1'ed and bookmarked

Share this post


Link to post
Share on other sites
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]http://www.youtube.com/watch?v=H4vmLX8HwF8[/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++. Edited by Kasc

Share this post


Link to post
Share on other sites
@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): [url="http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/"]http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/[/url]

Share this post


Link to post
Share on other sites

This topic is 1958 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this