- Home /
Calculating required force for pushing a body to a desired position at once
Hi!
In a 3D world I simulate that a coin is being pushed over a plane (applying a force in his rigidbody where y-axis = 0) using a top-down view.
Some time ago but using Box2D, I was able to calculate the amount of force required to stop the coin in a desired position with just one push.
Box2d-js
var fps=60;
var groundFriction = 0.01;
var force= new Box2D.Common.Math.b2Vec2(distance.x*coin.box2dBody.GetMass()*fps*(groundFriction*fps),distance.y*coin.box2dBody.GetMass()*fps*(groundFriction*fps));
coin.box2dBody.ApplyForce( force, coin.box2dBody.GetWorldCenter(), true );
In order to simulate the friction, during the update, I substracted the groundFriction(0.01) to the linearvelocity of the objects in movement in every frame.
Now using Unity with a more complex physics engine I cant replicate the same.
Unity3d
Vector3 posFinal = transform.position + direction * distFinal;
Vector3 distanceVecFinal = posFinal - transform.position;
float fps= 1/Time.fixedDeltaTime //50 fps
Vector3 force = new Vector3(distanceVecFinal.x * myBody.mass * fps, 0, distanceVecFinal.z * myBody.mass * fps);
myBody.AddForce(force);
I think that in the final formula I should add the friction of the objects, but I am not sure how to do it. Maybe this is not the only thing that I should change.
I need help pls!
tl&dr Calculate the required force for making move an object to a desired position in a plane with just one push.
You should just assign physics materials to both the plane and the coin that will cause heavy friction ( I would start with using multiply) then you can just increase the drag on the rigidbody to simulate a slide to stop motion
Actually I have friction between the objects, I need to know the required force for the push.
Your answer
Follow this Question
Related Questions
Friction between two rigidbodies 0 Answers
How to get the friction (factor) of the surface that the player is sliding on 1 Answer
Returning a rigidbody back to its original x and z rotations through physics forces. 2 Answers
Get result (force & torque) of AddForceAtPosition? 2 Answers
Why is force only being added in the same direction? 1 Answer