Hello. I’m using a physics simulation to control the environmental effects on an object. I am running the simulation in another thread so when it finishes it returns the force and torque on an object and then sets of a new task. This unlocks it from the the tick and also makes efficient use of multi-threading. I am however, getting weird results.
When I first tested my system I had it call AddForceAtLocation for each force generated. It gave me good results but I thought it was inefficient and I wanted the async task to return a single force and torque.
What I did was just sum all the forces and torques where for each force i:
TotalForce += Force_i;
// Both in world location
FVector R = ForceLocation - CenterOfMass;
FVector Torque_i = R^F;
TotalTorque += Torque_i;
Then once I had all the force I could simply:
Mesh->AddForce(TotalForce);
Mesh->AddTorque(TotalTorque);
The torques are giving me crazy results. They cause my object to spin around and move in unexpected ways and stabilize standing on their nose sometimes.
I have applied the forces independently to confirm that they are giving the expected results. The forces alone work well and will control the position of the object as expected but the torques are just crazy. I have confirmed that the force position is correct in regards to the center of mass.
I feel like I must be doing something silly or simple that is wrong. I’m exhausted from debugging so my mind is warped in weird ways. What is wrong with my code.