Game Development Community

Applied force to an object, initialForce set to 0 but it still moves?

by Steve De George · in Torque X 2D · 03/11/2010 (7:39 am) · 6 replies

My min\max of the force is set to -5/+5. The initial force value is set to 0. When I start the game, the object starts moving because of the force. If I delete the force, and run again, it doesn't move.

Am I wrongly interpreting what initial force does?

#1
03/16/2010 (9:29 am)
Does anyone use force? Or does this just not happen to anyone but me? :(
#2
03/16/2010 (10:00 am)
Luke uses the force.


...sorry, that was entirely unhelpful, but I couldn't resist ;)
#3
03/16/2010 (10:11 am)
LOL nicee
#4
04/01/2010 (4:45 pm)
Ok I tracked it down finally. Putting a negative value on the force min causes the problem. I was using a negative value to use the force in the opposite direction. The correct way to do this is to have another force that is rotated to face the other direction.

Just for reference, I tracked it down to the T2DForceComponent.MasslessForce class. In the UpdateForce method is this calculation which doesn't play nice with negative numbers:

strength = strength * (MaxStrength - MinStrength) + MinStrength;
#5
04/01/2010 (7:33 pm)
I set the force to vector2.zero to stop something dead. the force can be positive or negative.

#6
04/02/2010 (12:12 pm)
How do you modify the force on the object through code? I have a few diff forces which are all set to 0 for initial. Changing initial doesn't really do anything mid-game. I thought maybe I needed to use the ForecInstances, but they don't have names, so I cannot figure which is which.

Think of lunar lander as an example. I have jets on all four sides of the craft and want to turn some on\off.