# tokamak's setforce and applyforce

This topic is 5402 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Just a few more questions regarding the Tokamak Physics SDK... I am writing a simple bumper cart game, where the carts and other objects will generally be of the box or sphere shape so Tokamak works perfect for that. I have figured out how to set an animated body for the floor, and also how to setup box objects in the API. I've tested how gravity works and that seems fine, however my next major step is the force interactions between carts, and so I have a question about this: To accelerate my bumper carts, should I use setforce or applyimpulse, and also with these functions are their positions absolute world coordinates or with respect to the coordinate system of the object? I assume the bare minimum I would need to know are how to set a force to the back of the cart for acceleraton and perhaps a force to its side for turning? The rest, namely the collisions and interactions of the carts, would naturally be handled by tokamak. [Edited by - Khaos Dragon on October 5, 2004 8:49:54 AM]

##### Share on other sites
Hmm well I've had some success messing around with it... from what I gather the values passed to setforce and setimpulse are vectors with respect to the absolute world. Also setforce seems to apply a constant force, while setImpulse applies that force only for the current time slice.

So I guess for cart acceleration I should apply an impulse (until the max velocity is reached) pointing normally into the back of the cart. I am not sure exactly how to model turning though.

##### Share on other sites
One simple way to accomplish turning is to include that side force you mentioned. If you apply it at the center-of-mass, the car body won't turn, but the center-of-mass will follow a curved path. Remember that you'd have to keep rotating the side force in world space to be perpendicular to center-of-mass velocity; otherwise, if you keep the force aligned perpendicular to the unrotating car body you'll get a parabolic-=ish path---kind of like a projectile experiencing gravity, just on its side.

To get the body to rotate, you could directly apply a torque about the center-of-mass, or apply the side force at the wheels---fore and aft of center-of-mass. When the forces are applied offset from the center-of-mass, you get a torque due to the forces and this causes the body to rotate. In this case, you'd want equal but opposite forces so the net side force is zero and the only net force is the one parallel to the car's axis of symmetry, but a nonzero torque to turn the car.

Does that make sense at all? I have a cold and may not be thinking completely straight.

##### Share on other sites
I should also say that the magnitude of those equal-but-opposite side forces would determine your turning radius. AND, you *could* have non-equal-but-opposite side forces on the front and back tires...this is a way to simulate a sideways skid.

If you search the forum archives, I'm certain you'll find many prior discussion on vehicle dynamics!

• 18
• 29
• 11
• 21
• 16