A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Calling all New Unity users! Join the Halloween Mods Showcase Challenge until October 31.
Discussion in 'Physics' started by XiCHR15iX, Aug 27, 2019.
How do I check the current relative force of an object, e.g. speed a car is traveling?
if we consider the speed as the amount of velocity in the forward direction, you could use a dot product
speed = Vector3.Dot(rigidBody.velocity, transform.forward);
Force and speed are different properties.
Speed is simply rigidbody.velocity.magnitude. Taking the forward projection would make the value oscillating largely if the car is not moving forward, i.e. drifting or sliding laterally.
As you're mixing "force" and "speed" in your question then you may be referring to the momentum, which is mass times velocity. The magnitude of the lineal momentum of the car is simply rigidbody.velocity.magnitude * rigidbody.mass.
I'm not that level but i don't see how a simple calculated data could make an object drifting unless we use it in a drift formula. And we take the transform.right projection. here, its just a float...
drifting could be obtained by :
1. Calculating the sideway speed (A float )
2. Calculating Side Friction (A vector3 function of the float above and the transform.right projection using Time.fixedDeltaTime and dividing it by a certain amount to have (or not) a drift/slide behaviour...
3. Then Apply the calculated Side Friction as a Force. rigidBody.AddForce(sideFriction).