Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

How can I calculate the angular speed?

Discussion in 'Physics' started by Compressed, Dec 19, 2015.

  1. Compressed


    Sep 20, 2014
    Let's say I have some game object with a bunch of children game objects and they have colliders and meshes, and such. I attach a rigidbody to this game object and set the mass to 1000.

    The velocity and angular velocity are both zero at this moment.

    Then i attach a script to that game object and do this (once)
    Code (CSharp):
    2. GetComponent<Rigidbody>.AddTorque(Vector3.up*5000,ForceMode.VelocityChange);
    How do i calculate how fast will the game object start rotating (in radians/second) around that given axis?
    (I can't use rigidbody.angularvelocity, because i need to calculate the speed change before i actually apply the force via addtorque).

    if I needed to do the same thing for normal velocity and not the angular one, I would simply do addedForce/rigidbody.mass to get the speed change in m/s after that force is applied.

  2. Partel-Lang


    Jan 2, 2013

    Since you're using ForceMode.VelocityChange, the angular velocity delta will be exactly what you provided in the AddTorque call (Vector3.up * 5000). Only it will be clamped down to Rigidbody.maxAngularVelocity that is 7 by default so using a value like 5000 does not make any sense. When using VelocityChange, mass will be ignored. So in this case, the resulting velocity will be
    Code (CSharp):
    1. Vector3.ClampMagnitude(rigidbody.angularVelocity + Vector3.up * 5000, rigidbody.maxAngularVelocity);
    For linear velocity it's the same, only you don't need to clamp it and again, no dividing by mass when using VelocityChange.