I’m trying to make a button that makes a variable in another script true but i get this error every time. Please help. Code:
Error: NullReferenceException: Object reference not set to an instance of an object
Gui.OnGUI () (at Assets/Scripts/Gui.js:29)
#pragma strict
var moveButtonHight : int;
var moveButtonWidth : int;
var attackButtonHight : int;
var attackButtonWidth : int;
var tempName : String = "hi";
public var CreateCharacter : boolean = false;
function Start () {
}
function Update () {
}
function OnGUI() {
if (GUI.Button(Rect(Screen.width / 2, Screen.height - moveButtonHight, moveButtonWidth, moveButtonHight), "Move")){
Debug.Log("Clicked move");
var player = GameObject.Find("player").GetComponent(player).Moving;
//var com = player.GetComponent(player);
player = true;
}
if (GUI.Button(Rect(Screen.width / 2 - attackButtonWidth, Screen.height - moveButtonHight, attackButtonWidth, attackButtonHight), "Attack / Defend")){
Debug.Log("Clicked Attack / Defend");
}
if (Input.GetKeyUp(KeyCode.C)){
Debug.Log("creating character");
tempName = GUI.TextArea (Rect (Screen.width /4 , Screen.height / 4, 200, 100), tempName, 16);
}
}