- Home /
Calculating the force required (Rigidbody)
Hi,
i was wondering how i could calculate how much force i would need to apply to a rigibody to get a certain speed (velocity.magnitude, lets say its 50 for this example) providing i have the following settings on my rigidbody
No Gravity Everything else is set to default with the exception of drag Drag = 5
so i have drag(5) and velocity.squaremagnitude (50), now i need to calc how much force i need to apply. to get my speed (velocity.squaremagnitude (50))
Answer by khoramsql2008 · Nov 01, 2013 at 03:15 PM
force=1/2*mv*v which m is mass and v is velocity.
Answer by brenosilver · Jan 06, 2015 at 11:45 PM
I've put a couple of answers together and came up with this:
Vector3 forwardSpeed = (rigidbody.transform.forward * desiredSpeed);
Vector3 force = (forwardSpeed.normalized * rigidbody.mass * desiredSpeed);
force = (rigidbody.drag*force)/(1-0.02f*rigidbody.drag);
rigidbody.AddForce(force);
This works perfectly for me as you can see here.
The console shows TopSpeed which calculates the terminal speed with a given force/drag/mass:
float terminalVelocity = ((force.magnitude / rigidbody.drag) - Time.fixedDeltaTime * force.magnitude) / rigidbody.mass;
and Speed which is just the value of the slider or desiredSpeed. If both are equal that means the math works =)
Answer by Woj_Gabel_FertileSky · Mar 30, 2015 at 11:02 PM
This will not work when gravity is in play and collider is touching other collider, like a box on a flat plane. The equation needs to have this drag taken into account.
Your answer
Follow this Question
Related Questions
adding drag to a relative force 0 Answers
Touch controlled ice puck 0 Answers
Calculate force for torque by specifying a required velocity 1 Answer
Add force based on drag speed 4 Answers
How to negate this force? 2 Answers