Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Achieving oldschool platformer physics


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 wolfscaptain   Members   -  Reputation: 200

Like
0Likes
Like

Posted 26 July 2012 - 02:10 PM

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, 26 July 2012 - 02:13 PM.


Sponsor:

#2 Kaze   Members   -  Reputation: 948

Like
0Likes
Like

Posted 26 July 2012 - 02:19 PM

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.

#3 Postie   Members   -  Reputation: 1087

Like
0Likes
Like

Posted 27 July 2012 - 12:01 AM

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.
Currently working on an open world survival RPG - For info check out my Development blog: ByteWrangler

#4 wolfscaptain   Members   -  Reputation: 200

Like
0Likes
Like

Posted 27 July 2012 - 12:16 AM

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

#5 Postie   Members   -  Reputation: 1087

Like
1Likes
Like

Posted 27 July 2012 - 06:33 PM


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" Posted Image


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.
Currently working on an open world survival RPG - For info check out my Development blog: ByteWrangler

#6 wildbunny   Members   -  Reputation: 550

Like
1Likes
Like

Posted 28 July 2012 - 05:30 AM

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.

#7 6677   Members   -  Reputation: 1058

Like
0Likes
Like

Posted 31 July 2012 - 10:39 AM

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

#8 Kasc   Members   -  Reputation: 119

Like
0Likes
Like

Posted 02 August 2012 - 06:09 AM

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

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, 02 August 2012 - 06:12 AM.


#9 raigan   Members   -  Reputation: 731

Like
0Likes
Like

Posted 02 August 2012 - 08:22 AM

@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/




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS