[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 - How do you make a ball not lose speed when colliding

How do you make a ball not lose speed when colliding

Official forum for the .

How do you make a ball not lose speed when colliding

Postby hoan » Tue Jul 01, 2008 9:41 pm

hoan
 
Posts: 5
Joined: Tue Jul 01, 2008 9:37 pm

Re: How do you make a ball not lose speed when colliding

Postby Michael Buckley » Tue Jul 01, 2008 10:57 pm

cpBodySetAngle will rotate the ball around the center. It will not rotate the direction of the ball. It looks like the collision function is returning 0, which means "do not collide." Chipmunk will automatically calculate the angle at which the balls collide and take care of setting the proper velocities and accelerations for both balls if the function returns 1. You don't have to calculate the angle yourself.
Michael Buckley
 
Posts: 46
Joined: Tue Aug 21, 2007 10:30 am

Re: How do you make a ball not lose speed when colliding

Postby hoan » Wed Jul 02, 2008 3:21 am

Okay, so cpBodySetAngle does the wrong thing. I just want ball 1 to change direction, but keep the same velocity. I don't want ball 2 to be affected... is there a function that can do this? I'm returning 0 because I want to process the collision myself, however is it better to return 1, and then change the velocity after cpSpaceStep finishes?

Thanks for your time
Hoan
hoan
 
Posts: 5
Joined: Tue Jul 01, 2008 9:37 pm

Re: How do you make a ball not lose speed when colliding

Postby hoan » Wed Jul 02, 2008 3:36 am

hoan
 
Posts: 5
Joined: Tue Jul 01, 2008 9:37 pm

Re: How do you make a ball not lose speed when colliding

Postby hoan » Wed Jul 02, 2008 2:59 pm

hoan
 
Posts: 5
Joined: Tue Jul 01, 2008 9:37 pm

Re: How do you make a ball not lose speed when colliding

Postby Michael Buckley » Wed Jul 02, 2008 9:00 pm

If you don't want the balls to affect non-ball objects, you can either filter the collisions using the collision pair function or put the balls on their own collision layer.
Michael Buckley
 
Posts: 46
Joined: Tue Aug 21, 2007 10:30 am

Re: How do you make a ball not lose speed when colliding

Postby hoan » Thu Jul 10, 2008 4:19 am

I don't know if I made myself clear. There are 2 types of balls in the game, a and b. When ball a hits ball b, I want ball a's velocity to remain the same, but its direction to change. I also want ball b's angle and velocity not to change.

So I've also tried setting the mass of ball B to INFINITY and ball A to 0, but nothing changes. Any ideas?
hoan
 
Posts: 5
Joined: Tue Jul 01, 2008 9:37 pm


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 0 guests

cron