- Home /
Getting contact force between two rigidbodies
I would like to know if there is a way of getting the contact force (aka normal force in physics) between two rigidbodies. Not just in a case of a collision, but also when a rigidbody stands still on top of another rigidbody. I know in pure Physx that information is acessible for use, but in unity I counldn't figure out a way to access it.
I'm needing it to correct the slip-based model for the wheel colliders the physx uses, because as I understand, the model takes the slip between the wheel and the road to calculate the friction force, but doesn't take in account the normal force between both. The result is that the friction can get the same values both on a horizontal floor, or on a ramp, and even on a wall. Just a slight contact can get full friction force.
So my idea to solve this was multiplying the stiffness factor by the normal force between the road and the wheels.
So that is the problem. Anyone has any idea? Or a diferent approach on solving this? What I need is a more realistic wheel behavior for my game, so the vehicle stop climbing mountains =P
Thanks in advance! =)
if you have a character controller on your vehicle you can set it's slope offset limit which means it will stop climbing mountains, might be worth adding that as a hardstop for your vehicle, as well as altering the wheel physics to get it looking how you please.
I too have wanted access to the current force and torque accumulators on the rigidbody. I am currently just using a wrapper to keep track of this myself, but obviously this misses forces that don't know about the wrapper. Note that you would still miss impulses since these modify the velocity immediately rather than being accumulated in a force vector.
I'm starting to think that there is no way to solve this =(
Answer by Edy · May 20, 2011 at 08:55 PM
WheelHit.force
However, the force (and thus the friction) depends on the surface's own inclination. If you are climbing mountains the angle between the WheelCollider and the surface's normal is still around 0, so reducing the grip according to this angle wouldn't change the result.
But as the terrain becomes more inclined then the force will be reduced, thus reducing the grip as well. This should reach a point where the car can't climb further due to the low friction. So your problem seems to be caused because you're still using the default WheelCollider friction parameters. They denote a tire with almost infinite grip, so the car will climb anything. Just reduce the stiffness parameters (both forwards and sideways) to 0.01 - 0.04 and you'll get more real behavior.
Here you can see a demo of WheelColliders working properly:
http://www.edy.es/unity/offroader.html
Your answer
Follow this Question
Related Questions
Raycast Car-Vehicle Physics 1 Answer
Pushing a cart with a vehicle (Not generating initial torque) 0 Answers
Wheel Collider not consistant when spinning 0 Answers
Realistically drivable car 0 Answers
Car not turning on plane. 1 Answer