[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/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 - Disabling momentum transfer

Disabling momentum transfer

Official forum for the .

Disabling momentum transfer

Postby JEisen » Sat Dec 24, 2011 9:28 pm

I'm working on my first experiments using Chipmunk (in fact, it's my first foray into non-text-based games) so I'm trying to use a few of the standard libraries to get to know them better. I should also note, as a caveat, that while I've taken (and passed) basic university-level physics classes, I can't say that I'm great at applying them to full systems (and besides which, it's been a while since I took them.)

Anyway, that's a roundabout way to say that I'm running into a conceptual issue with Chipmunk, and while I know a workable answer would be "Don't use Chipmunk", I'm going with the idea that learning how to force it into the API (or even that it's just not possible) will teach me more about the framework than I'd otherwise get.

So here's the issue. I'm writing a simple Jezzball-like game, where the only objects are walls and bouncing balls. To give it the classic bouncing effect, I'm using no damping and perfect (1.0) elasticity on each ball and the walls. As I place balls into the area, I put it in a random position, set its rotation angle to (rand * (2*PI)), then apply a constant impulse of Vector(cos(angle), sin(angle)).

The problem is that this method works too well -- when a ball hits a wall, it bounces off in a new direction with its proper momentum still intact. But when two balls collide, there's transfer going on, so eventually, I'll have some balls just chugging along slowly and others zipping around the space like rockets. What I'd like to do instead is have the balls ricochet off of each other into the direction they'd go with the realistic method but with constant momentum.

What would be the best way to handle this? Replace the entire collision handler for balls hitting each other? Adding a post_collision handler that corrects it? Something else?
JEisen
 
Posts: 3
Joined: Sat Dec 24, 2011 9:00 pm

Re: Disabling momentum transfer

Postby slembcke » Sun Dec 25, 2011 12:31 pm

I'm currently working on a physics breakout game (for a contract so I can't share the code), but what I did was to reaccelerate the ball towards it's ideal velocity a little each frame. It works really well in practice. You just have to find a suitable acceleration amount so that the physics stays stable, but the ball doesn't look like it slowly accelerates back to normal speed. It's just a matter of tweaking though.
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: Disabling momentum transfer

Postby JEisen » Sun Dec 25, 2011 11:37 pm

Without going into too much code detail, I suppose, what would the formulas look like in those steps? How would I calculate the impulse (or force?) I'd have to apply to get it back to the speed I want?
JEisen
 
Posts: 3
Joined: Sat Dec 24, 2011 9:00 pm

Re: Disabling momentum transfer

Postby slembcke » Mon Dec 26, 2011 12:25 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: Disabling momentum transfer

Postby JEisen » Mon Dec 26, 2011 1:34 am

I just had a long post written about how that still wasn't working, then I adjusted the numbers and suddenly it all fell into place. It still looks a little unnatural, but I'm justifying it as saying that Jezzball itself represented an unnatural state, and this is just a slightly different unnatural state. It's a little weird to see the balls hit and continue in roughly the same direction at their "normal" speeds, but I'm accepting it. Thanks!
JEisen
 
Posts: 3
Joined: Sat Dec 24, 2011 9:00 pm


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 0 guests

cron