GetComponent<Rigidbody>().velocity.magnitude code example
Example 1: get rigidbody component unity
//The Variable
Rigibody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
Example 2: unity how to set rigidbody velocity
Vector3 velocity = new Vector3(10f/*x*/, 10f/*y*/, 10f/*z*/);
GetComponent<Rigidbody>().velocity = velocity;
Example 3: rigidbody velocity c# unity
//for rigidbody2D
GetComponent<Rigidbody2D>().velocity =new Vector2(40,0);
Example 4: rigidbody velocity
rb.velocity = new Vector3(0, 10, 0);