Basically Im trying to access a function GetLives() in a script called obj. However Im having an error in my function update when I run the game.
using UnityEngine;
using System.Collections;
public class PickUpController : MonoBehaviour
{
public int objCount;
public GameObject playerHandle;
GUISkin gskin;
void OnGUI()
{
if(gskin)
{
GUI.skin = gskin;
}
string guistring = "Candy: " +objCount;
guiText.text = guistring;
GUI.Label (new Rect( 20, Screen.height-230, 150, 250), guistring);
}
void Update()
{
playerHandle = GameObject.Find("Player");//reference to the Player GameObject within the scene
obj other;
other = playerHandle.GetComponent("obj") as obj;
objCount= other.GetLives();
}
}