- Home /
Question by
Smaika · Apr 28, 2014 at 04:56 PM ·
speedspeedometer
How to Calculate rigidbody2D velocity and display it on a label?
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.
Comment
Answer by robertbu · Apr 28, 2014 at 04:56 PM
Try:
GUI.Label (Rect (10, 10, 100, 20), speed.ToString());
Your answer
Follow this Question
Related Questions
how to setup speedoprefab 0 Answers
Moving needle from one angle to another angle one time 1 Answer
Car speedometer MPH 1 Answer
Having a speed counter 2 Answers
Speed car at the start of the game 1 Answer