I'm planning to implement Chipmunk in iOS, but before I do, I need to know if I can apply gravity to the z-axis. Imagine something like a top-down game where balls roll around or something. Gravity should be pulling through the back of the device, and not from any of the sides.
Is this possible?
SOLVED:
http://chipmunk-physics.net/forum/viewt ... 8684#p8684
Gravity Along Z
-
- Posts: 3
- Joined: Fri Dec 09, 2011 6:49 pm
- Contact:
Gravity Along Z
Last edited by inveni0 on Sat Dec 10, 2011 8:58 am, edited 1 time in total.
-
- Posts: 24
- Joined: Wed Mar 16, 2011 12:17 pm
- Contact:
Re: Gravity Along Z
If I understand you right, you want to do something like this?
http://www.mepix.info/varomex/hlo/1512.jpg
A gravity which is goes "through" your plain and nails a marble on the ground?
As far as I know there is no build in function in chipmunk for it (cause its a 2d physic engine ), however you can implement this (fake) gravity by yourself.
In this case (if you assume that the marble always touches the ground and cant "fly") its not very difficult.
For example the board is parallel to the ground, no additional force will take effect on the marble. But if you change the board for example around the Y axis, the marble will roll along the X axis.
So all you have to do is to project the gravity Z axis on the X/Y plane and add the force to the marble. The math behind it is not that difficult (sine / cosine etc).
http://www.mepix.info/varomex/hlo/1512.jpg
A gravity which is goes "through" your plain and nails a marble on the ground?
As far as I know there is no build in function in chipmunk for it (cause its a 2d physic engine ), however you can implement this (fake) gravity by yourself.
In this case (if you assume that the marble always touches the ground and cant "fly") its not very difficult.
For example the board is parallel to the ground, no additional force will take effect on the marble. But if you change the board for example around the Y axis, the marble will roll along the X axis.
So all you have to do is to project the gravity Z axis on the X/Y plane and add the force to the marble. The math behind it is not that difficult (sine / cosine etc).
-
- Posts: 3
- Joined: Fri Dec 09, 2011 6:49 pm
- Contact:
Re: Gravity Along Z
Yes. Your example isn't what I'm programming, but it uses the same physical rules. Another example would be UIViews acting like papers on the surface of a table.
I know I can program some basic acceleration and deceleration, but I was hoping to use Chipmunk to handle the collisions between a number of different "papers" or "marbles".
I know I can program some basic acceleration and deceleration, but I was hoping to use Chipmunk to handle the collisions between a number of different "papers" or "marbles".
-
- Posts: 24
- Joined: Wed Mar 16, 2011 12:17 pm
- Contact:
Re: Gravity Along Z
Im not sure what you exactly want, but collisions can act on different layers (see manual "Chipmunk Collision Shapes: cpShape") to simulate some layers above each other or something like that.
Is maybe that what you want?
Is maybe that what you want?
-
- Posts: 3
- Joined: Fri Dec 09, 2011 6:49 pm
- Contact:
Re: Gravity Along Z
No. Remember the example you posted? I want something like that, but pretend there are multiple steel balls that can collide with eachother. THAT'S where I was hoping Chipmunk could save time.gnasen wrote:Im not sure what you exactly want, but collisions can act on different layers (see manual "Chipmunk Collision Shapes: cpShape") to simulate some layers above each other or something like that.
Is maybe that what you want?
EDIT:
Okay, I figured out what I need to do to get what I'm looking for. Basically, all I have to do is set gravity to zero and damping to whatever feels right. Something like this works:
Code: Select all
space->damping = 0.4;
Who is online
Users browsing this forum: No registered users and 16 guests