[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 - Rotating a Rogue Body around a bouncing ball

Rotating a Rogue Body around a bouncing ball

Official forum for the .

Rotating a Rogue Body around a bouncing ball

Postby jsMilton » Mon Oct 01, 2012 8:31 am

jsMilton
 
Posts: 3
Joined: Fri Mar 30, 2012 1:02 pm

Re: Rotating a Rogue Body around a bouncing ball

Postby slembcke » Mon Oct 01, 2012 10:14 am

You need to update both the angular velocity and position of the frame's body or the collision response won't work correctly.

Think of this simple example: A wall is moving to the right as 5 units/second. You are changing the wall's position at that rate but leave it's velocity at 0. A ball moving left hits that wall and reacts as though the wall were not moving (after all, it's velocity is 0). So now the ball stopped and it's velocity is 0 (it wasn't bouncy at all). Next frame, you move the wall to the right more and it's overlapping the ball now. The collision response runs again but sees that the collision velocities are already resolved. Both have a velocity of 0. They ball and wall are overlapping now, so Chipmunk pushes them apart gently to resolve the overlap (but possibly less than at 5 units/second).

The same thing happens with the angular velocity, it's just a little more complicated. What I do in the Tumble demo is to set the angular velocity of the rotating box at init time and then each frame call cpBodyUpdatePosition() which updates the position (and angle) based on its velocities. So the velocity and positions never get out of sync. You can do the same, you just need to calculate the angular velocity you want.
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: Rotating a Rogue Body around a bouncing ball

Postby jsMilton » Mon Oct 01, 2012 11:51 am

Hey Scott,

Thats fixed it! Thanks a bunch :D

One thing now is that the velocity of the ball keeps changing every time it hits a spinning side! The spinning frame is just meant to redirect the ball, leaving the velocity the same. Is this possible, or is it just natural for chipmunk to alter the velocity like this ?
jsMilton
 
Posts: 3
Joined: Fri Mar 30, 2012 1:02 pm

Re: Rotating a Rogue Body around a bouncing ball

Postby slembcke » Mon Oct 01, 2012 12:57 pm

Well, it wouldn't be conserving momentum and wouldn't be a realistic simulation if the speed stayed the same.

I've worked on breakout-like games before where you always want the ball to have a more or less constant velocity. What I did in that case was to always be accelerating the ball back to it's natural speed. So after a collision, the ball would speed up or slow down, then accelerate up or down to get back to it's regular speed over a short amount of time (like a quarter of a second or something). It worked pretty well.
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: Rotating a Rogue Body around a bouncing ball

Postby jsMilton » Mon Oct 01, 2012 3:01 pm

Yeah I get that it would be unrealistic, but it's necessary as the app is actually a generative music maker, where the collisions act as notes for a sampler. A constant speed is good for repeating rhythms :P

Thanks for the help and advice, I really appreciate it.

As for the Chipmunk library, I definitely plan on doing some more interesting stuff with it in the future. It looks like an awesome tool!

Cheers,

James
jsMilton
 
Posts: 3
Joined: Fri Mar 30, 2012 1:02 pm

Re: Rotating a Rogue Body around a bouncing ball

Postby slembcke » Mon Oct 01, 2012 4:56 pm

Thanks. :)
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: Rotating a Rogue Body around a bouncing ball

Postby gnasen » Tue Oct 02, 2012 2:09 am

gnasen
 
Posts: 24
Joined: Wed Mar 16, 2011 12:17 pm

Re: Rotating a Rogue Body around a bouncing ball

Postby aisman » Tue Oct 02, 2012 6:36 am

Chipmunk4PB: The fastest way to write games together with PureBasic and the Chipmunk physics engine.
User avatar
aisman
 
Posts: 144
Joined: Tue Mar 04, 2008 2:21 am


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 4 guests