how to get velocity of object in unity code example
Example 1: unity get velocity of gameobject
Rigidbody rb = GetComponent<Rigidbody>();
rb.velocity; // Velocity of gameObject (Vector3)
Example 2: rigidbody.velocity.magnitude
//speed of rigidbody in m/s
float speed = rigidbody.velocity.magnitude;