How to Calculate rigidbody2D velocity and display it on a label?
I have the following script on my Game object I want to Show its Velocity and a rigidbody2d attached to it
that what I got so far
#pragma strict
var speed : float;
function Update () {
speed = rigidbody2D.velocity.magnitude;
}
function OnGUI () {
GUI.Label (Rect (10, 10, 100, 20), speed);
}
But I got this error:
Assets/SpeedView.js(9,27): BCE0023: No appropriate version of ‘UnityEngine.GUI.Label’ for the argument list ‘(UnityEngine.Rect, float)’ was found.