- Home /
How do I get force applied on an object by unity physics?
Suppose I add a force of 10N to a rigidbody (rigidbody.AddForce) and due to external forces such as collisions, friction, air drag etc the net force applied on the body is now reduced. Is there a way to get the force applied by these 'other' factors.? When does unity calculate all these forces. Suppose I add the force in fixedUpdate is there any way for me to calculate these 'other' forces using velocities obtained from two consecutive fixedUpdate calls?
I did an experiment on this, when you add force or torque it will be converted to velocity and angular Velocity in the NEXT fixed update cycle. So all the other forces will start affecting from next fixed update call.
I added (10,0,0) force to sphere and debuged the velocity before and after that, and Drag was 0.5 and results were obvious.
frame num | velocity.x
0 | 0 (force was added in this cycle)
1 | 5 (force * drag)
2 | 0.25
and so on...
to debug physics you can change Time.fixedDeltaTime to higher value 1 and use Editor Steps. Hope this helps.
Thanks Yash for your comments. It did help me out and provided me some ideas to deal with my problems.!
Your answer
Follow this Question
Related Questions
How to add force to rigid body in a direction of another object? 1 Answer
Game not running properly on slow machines (low fps) 1 Answer
How to make an object moving in a certain direction, move in specific steps like 0.1f 1 Answer
Rigidbody velocity limiter 0 Answers
Fix an object against forces 1 Answer