Calculating speed of rigidbody?

I have a car and it's a rigidbody with a force acting on it. How would i make a "public var" showing the speed so i can play in small screen and see the speed on the side bar?

var speed = rigidbody.velocity.magnitude;

didn't work like that^^^^^^^

var speed = rigidbody.velocity;

or like that^^^^^^^^

var speed = rigidbody.velocity.magnitude;

Why didn't this "work"? How do you quantify success here? The magnitude of the velocity is what you need, it'll return the velocity of the object in meters per second (assuming you're using the spatial units in Unity as meters, which you should).

It’s better to use FixedUpdate rather than simple Update whenever dealing with physics (rigidbody) objects, that in your case is a car. If you want to have a detailed idea of what’s the difference between them, please visit the following link: