So, I want my character to be able to collect cheese cubes. I have the GUITexture positioned through the inspector, a GUIText (“Collected:”) that says that next to the texture, and then I have a blank GUIText (called “Counter”----creative, i know—) that is positioned next to it. I am getting no errors or compiler issues with this code, but it isn’t doing what I thought it would. I am a newbie, so please internets, tell me how to get an active counter of cheese cubes to show up on screen next to my GUITexture!
private var CollectedCheese : int= 0; //Set up a variable to store how many you've collected
public var collectedSound : AudioClip;
var CheeseCube : GameObject;
var cheeseTexture : GUITexture;
var Counter : GUIText;
CheeseCube.SetActive(true); //Using True/False techno
function OnTriggerEnter (myTrigger : Collider)
{
if (myTrigger.gameObject.name == "Rat")
{
audio.PlayOneShot(collectedSound); //plays the sound assigned to collectedSound
CollectedCheese++; //adds a count of +1 to the collected variable
CheeseCube.SetActive (false); //turns the collectable off
}
if (CollectedCheese >= 1.0 + CollectedCheese)
{
Counter.GUIText.text = ("CollectedCheese");
Counter.transform.localPosition.x=-390.2;
Counter.transform.localPosition.y=348.08;
}
}
Please and thank you!