best way to simulate/fake top-down physics?

Official forum for the Chipmunk2D Physics Library.
Post Reply
raden_muaz
Posts: 9
Joined: Sat Nov 01, 2008 9:52 am
Contact:

best way to simulate/fake top-down physics?

Post by raden_muaz »

what is the best way to simulate/fake top-down physics in chipmunk?
I see that chipmunk hasn't implemented some top-down friction, etc yet
PeskyJ
Posts: 19
Joined: Fri Apr 24, 2009 4:24 pm
Location: Reading, UK
Contact:

Re: best way to simulate/fake top-down physics?

Post by PeskyJ »

I haven't tried this yet, but using a snooker/pool table as an example I would start off by setting gravity in the space to zero (cpvzero) and applying a light damping effect, say damping = (cpFloat)0.95. Then I would tweak from there. That should get you a basic top-down effect. All the balls would be added normally and the cushions added as static objects.

To go further with the pool example, elasticity would be quite high, you'd have to play with friction on the balls/cushions to get spin to work. You could even model the cue with a high friction tip and put it in a collision plane (using the layers field) that most balls are *not* in, then only add the cue ball to that plane.
Games games games... I love games. Check out my games: [url]http://www.tinyplay.com/games.html[/url]
raden_muaz
Posts: 9
Joined: Sat Nov 01, 2008 9:52 am
Contact:

Re: best way to simulate/fake top-down physics?

Post by raden_muaz »

PeskyJ wrote:I haven't tried this yet, but using a snooker/pool table as an example I would start off by setting gravity in the space to zero (cpvzero) and applying a light damping effect, say damping = (cpFloat)0.95. Then I would tweak from there. That should get you a basic top-down effect. All the balls would be added normally and the cushions added as static objects.

To go further with the pool example, elasticity would be quite high, you'd have to play with friction on the balls/cushions to get spin to work. You could even model the cue with a high friction tip and put it in a collision plane (using the layers field) that most balls are *not* in, then only add the cue ball to that plane.
how about a car? i tried applying impulse and force and it won't stop.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: best way to simulate/fake top-down physics?

Post by slembcke »

Oof. Cars are hard. There used to be a great tutorial on this, but it has disappeared from the webs.

Fortunately the web archive seems to have the most important bits:
http://web.archive.org/web/200504031212 ... monstrous/
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
PeskyJ
Posts: 19
Joined: Fri Apr 24, 2009 4:24 pm
Location: Reading, UK
Contact:

Re: best way to simulate/fake top-down physics?

Post by PeskyJ »

It depends what type of car simulation you want...

If it's a realistic one where the front tyres need to turn to an angle and deflect the front of the car sideways while the (front or rear) drive tyres provide a forwards force, and all the while the main body of the car can crash into other objects such as other cars and deflect them... then I would say this would be very difficult using Chipmunk and you should look for a much more complex solution.

On the other hand, if it's a micro-machines style car game, where the car is essentially a basic shape (or perhaps a few basic shapes if you want precise collision with bulging out wheels or whatever) that pushes forwards, rotates, and collides with things... then that's pretty easy with Chipmunk...

1) Like in the pool example, use a light damping effect and set gravity to zero.
2) Use a torque value on the body to "steer" (rotate) it. You will probably have to damp the torque manually yourself to prevent accelerating spin, however this is preferable to setting the angular velocity directly because that would kill any spin from collisions. Use a high torque value that quickly damps proportionally to the angular velocity. Also, you should have a "lose-traction" flag that damps your torque so recovering from spins is not instant.
3) Use the apply force function to apply a forwards acceleration to the car. You will need to play with the damping and the mass of your car to get the right "drift" effect round corners.

I think that should give you the basics of a toy racer.
Games games games... I love games. Check out my games: [url]http://www.tinyplay.com/games.html[/url]
ayqazi
Posts: 1
Joined: Tue Sep 15, 2009 1:00 pm
Contact:

Re: best way to simulate/fake top-down physics?

Post by ayqazi »

Hi,

I have a similar issue. I want to create a Zelda-like top-down game, and have got the whole damping thing - it works great.

However: I want different characters to have a different damping, if you know what I mean. So some characters will be sliding around because they have slick tyres on, while others will be moving will full control because they have rugged treads on their tanks.

Is this possible to do?

Thanks
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: best way to simulate/fake top-down physics?

Post by slembcke »

You can create your own velocity update function on a per body basis. This would make it easy to override the damping values calculated by the space and substitute your own on an individual basis.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests