applyCentralForce and applyCentralImpulse

kulebril
Posts: 10
Joined: Wed Jan 16, 2013 1:36 pm

applyCentralForce and applyCentralImpulse

Post by kulebril »

Hi!

Im using applyCentralForce to throw a ball when my character has the ball and throws it (like in baseball).

But, the ball seems to retain the impulse and adds new impulse each time.

What is the difference between applyCentralForce and applyCentralImpulse?
Which is the good one in this case?
Im trying to do parabollic effect throw.

thanks in advance
norbie
Posts: 21
Joined: Mon Feb 11, 2013 1:57 pm

Re: applyCentralForce and applyCentralImpulse

Post by norbie »

Hello,

both approaches are OK. The difference is that with applyCentralForce you need to apply a force for a period of time to really have the effect of throwing (so it is usually not enough to only call it once). During this period the ball gains speed because of the applied force.
On the other hand applyCentralImpulse is more like setting a velocity directly to your ball, please see its implementation:

Code: Select all

	void applyCentralImpulse(const btVector3& impulse)
	{
		m_linearVelocity += impulse *m_linearFactor * m_inverseMass;
	}
Or you could also think about it as a convenient function to apply a certain force for a certain amount of time in one step.

Hope that helps.