- Home /
Question by
user-335 (google) · Feb 25, 2010 at 09:29 PM ·
guigameobjectjavascript-specific
Display the speed of a Game Object in MPH
I am trying to display the speed of a game object in MPH using a GUI text. I think that my code is right because the GUI text is on the screen but it doesn't move past zero.
var myObject : GameObject;
var gui : GameObject;
function Update () {
//gui.guiText.text = "Speed: " + myObject.rigidbody.velocity.magnitude.ToString() + "m/s";
}
What am I doing wrong?
Comment
Answer by Kethis Celebes · Feb 25, 2010 at 09:35 PM
Well, um, its commented out. Try removing the // and see how it works. Also, it seems like text variable is capitalized (Text).
Also GUI functions should probably be done in OnGUI. Look up UnityGUI for more info, its a generally superior alternative.