[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/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 - Applying force doesn't do anything

Applying force doesn't do anything

Official forum for the .

Applying force doesn't do anything

Postby bronxbomber92 » Fri Aug 01, 2008 1:27 pm

I'm trying to add a simple force when my rigidbody collides with something. I know chipmunk doesn't zero forces, so in my update function I call cpBodyResetForces(). But, when I use this, the force seems to not have any affect, no matter what the magnitude of the force is (both 10 and 1000 have the same result)! My rigidbody's mass is 10, it's elasticity is 0.9 and it's friction coefficient is 0.0.

cpVect force = cpvmult(contacts[0].n, 30.0f);
cpBodyApplyForce(body, force, cpvzero);

What am I doing wrong?
Thanks
bronxbomber92
 
Posts: 8
Joined: Sat Dec 01, 2007 6:06 pm

Re: Applying force doesn't do anything

Postby Michael Buckley » Fri Aug 01, 2008 2:27 pm

Just for kicks, what happens if you remove the cpBodyResetForces() call?
Michael Buckley
 
Posts: 46
Joined: Tue Aug 21, 2007 10:30 am

Re: Applying force doesn't do anything

Postby bronxbomber92 » Fri Aug 01, 2008 3:01 pm

The forces works, but they are persistent.
bronxbomber92
 
Posts: 8
Joined: Sat Dec 01, 2007 6:06 pm

Re: Applying force doesn't do anything

Postby Michael Buckley » Fri Aug 01, 2008 4:21 pm

Then without seeing the whole code, it sounds like you're resetting the forces before they're actually acted upon. The forces don't get applied immediately. They get applied during a call to cpSpaceStep.
Michael Buckley
 
Posts: 46
Joined: Tue Aug 21, 2007 10:30 am

Re: Applying force doesn't do anything

Postby bronxbomber92 » Sat Aug 02, 2008 11:27 am

bronxbomber92
 
Posts: 8
Joined: Sat Dec 01, 2007 6:06 pm

Re: Applying force doesn't do anything

Postby Michael Buckley » Sat Aug 02, 2008 4:53 pm

I think the problem is that you're applying the forces in the collision function. IIRC, the collision function is called during cpSpaceStep after the forces are already applied, so any forces you apply in the collision function won't take effect until the next call to cpSpaceStep. Thus, your Update method is going to need to reset only the forces of the bodies that haven't had forces applied to them in the collision. You'll probably also have to zero the force of each body in the collision function before you apply a new force to it.
Michael Buckley
 
Posts: 46
Joined: Tue Aug 21, 2007 10:30 am

Re: Applying force doesn't do anything

Postby bronxbomber92 » Sat Aug 09, 2008 9:05 pm

bronxbomber92
 
Posts: 8
Joined: Sat Dec 01, 2007 6:06 pm

Re: Applying force doesn't do anything

Postby bronxbomber92 » Sun Aug 10, 2008 12:59 pm

Ok, I've found that this only happens when I add static shapes to the scene. Why would this be?
bronxbomber92
 
Posts: 8
Joined: Sat Dec 01, 2007 6:06 pm


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest