how to get rigidbody speed in unity

Code Example - how to get rigidbody speed in unity

                
                        var speed = rigidbody.velocity.magnitude;
                    
                
 

rigidbody velocity

                        
                                rb.velocity = new Vector3(0, 10, 0);
                            
                        
 

rigidbody.velocity.magnitude

                        
                                //speed of rigidbody in m/s
float speed = rigidbody.velocity.magnitude;