[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - Moving Platforms, Liquid, All the Funky stuff

Moving Platforms, Liquid, All the Funky stuff

Official forum for the .

Moving Platforms, Liquid, All the Funky stuff

Postby X-0ut » Tue Nov 20, 2007 8:29 am

I'm looking for some good solutions to some problems I encountered in a previous project using Chipmunk.
For moving platforms, I adjusted a static bodies position each step. Which worked great for moving the platform. Unfortunately any objects that came into contact with the platform would not move along with it. I hacked that in using collision pair callbacks, but it was fugly and didnt work very well.
An allternative method would be great, ideally I want platforms to follow splines. Maybe it can be accomplished using a joint, but note the platform must not be effected by gravity and must not rotate.

Liquid, another little hack I made was to simply damp the gravity of a body in contact with a water body. It worked ok for that project but I'd really like something with a bit more realistic behaviour. For instance, I'd like objects to float on water surface, or sink if they are too heavy etc.

And finally, a problem I encountered and could not solve. Stopping a body from rotating but still moving with a joint such as pivot.

If anyone has solved these problems or even has any ideas that could help me on my way, they would be very appreciated.

TIA
X-0ut
 
Posts: 28
Joined: Tue Oct 02, 2007 5:02 am

Re: Moving Platforms, Liquid, All the Funky stuff

Postby darwinian » Tue Nov 20, 2007 10:35 am

I implemented very basic moving platforms by simply adjusting the velocity of a dynamic body. The dynamic body is set up with infinite moment of inertia to prevent rotation, and a large mass so as not to be affected by, for example, the player jumping on it. It won't be affected by gravity as you are calculating the new velocity each frame yourself (then calling cpBodyUpdatePosition).

While this does work, it can be improved. I too was considering some path based movement for platforms. I thought it might be possible to represent the path as a spline and update the velocity based on the tangent at a specific point on the curve. A fully untested idea as of yet.

As for the problem of preventing a body from rotating but still moving with a joint, if I understand you correctly, shouldn't it just be a case of setting an infinite moment of inertia?

As for water, well I would love to hear of a good way of implementing it. I haven't tried yet, but it is on my feature list.
darwinian
 
Posts: 3
Joined: Tue Nov 20, 2007 10:15 am

Re: Moving Platforms, Liquid, All the Funky stuff

Postby X-0ut » Tue Nov 20, 2007 11:35 am

Ah I see, maybe thats where I was going wrong with the platforms. Instead of adjusting the position each step, I should alter the velocity. That is probably why nothing would sit ontop of them.
About the rotation I'll have to give that a try.

Liquids.. I've been thinking maybe I could attach a slide joint to a body that enters water etc. One end of the joint attaches to the objects center, and the other to the water surface.
The min/max would be based on the objects weight and the viscousity of the liquid. Its completely untested and I can see some cases in which it would break. Hoping for a better solution really.
X-0ut
 
Posts: 28
Joined: Tue Oct 02, 2007 5:02 am

Re: Moving Platforms, Liquid, All the Funky stuff

Postby slembcke » Tue Nov 20, 2007 1:27 pm

Yeah, as has already been said, if you are changing the position of the object, you must also change the velocity to match. Chipmunk uses Euler integration, so make sure that you are calculating the velocity from the delta of the positions. Using the derivative of the position (if you are doing something fancy like splines) won't work 100% right.

As far as liquids. I would keep it simple. Start by trying to apply a buoyant and damping force if the center of the object is in the liquid. For roughly symmetric shapes, I would think that would work pretty well. If the shape is more complicated, try using point sampling to estimate how much of the object is submerged and apply the buoyant and damping forces to the average of the submerged points.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Moving Platforms, Liquid, All the Funky stuff

Postby X-0ut » Tue Nov 20, 2007 2:05 pm

Ok thanks for all the answers, I think I got enough to be getting on with now.
X-0ut
 
Posts: 28
Joined: Tue Oct 02, 2007 5:02 am

Re: Moving Platforms, Liquid, All the Funky stuff

Postby slembcke » Thu Nov 22, 2007 5:07 am

Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Moving Platforms, Liquid, All the Funky stuff

Postby slembcke » Fri Nov 23, 2007 4:32 pm

Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Moving Platforms, Liquid, All the Funky stuff

Postby slembcke » Fri Nov 23, 2007 5:37 pm

Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Moving Platforms, Liquid, All the Funky stuff

Postby X-0ut » Sat Nov 24, 2007 9:05 am

Excellent! :)
X-0ut
 
Posts: 28
Joined: Tue Oct 02, 2007 5:02 am

Re: Moving Platforms, Liquid, All the Funky stuff

Postby joshcryer » Sun Nov 25, 2007 12:21 am

Sick! (As in cool.)
joshcryer
 
Posts: 18
Joined: Wed Sep 26, 2007 8:19 pm

Next

Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest

cron