Hi all,
Just a quick syntax question as the Unity documentation was pretty much useless in this regard. I am trying to fetch a variable from one script (float) and put it in another (as a string) that is constantly updating. I have perused the forums but found nothing of use in this regard. Here is my javascript so far:
At the moment the syntax is wrong for the GetComponent line. Can someone help me with this or point me at some good reference documentation?
Thanks in advance
I am now getting a NullReferenceException: Object reference not set to an instance of an object on the line starting with getHorSpeed
var horSpeed : String;
function Update ()
{
getHorSpeed = gameObject.GetComponent("PlayerMovement").horAcceleration.ToString();
var horSpeed: String = getHorSpeed;
}
function OnGUI ()
{
GUI.Box (Rect (Screen.width - 100, Screen.height - 50, 100, 50), GUIContent (horSpeed));
}
How do I reference the product of the ToString method?