- Home /
Count >= then object tag becomes active
"Pickup" the Diamonds. After 7 Diamonds have reached. Objective: The portal opens and the WinPad trigger is active.
This code runs but whenever I go over the Winpad its still active. I dont want it to be active until 7 diamonds have been met.
C#
using UnityEngine; using System.Collections;
public class PlayerController1 : MonoBehaviour {
public GUIText CountText;
public GUIText WinText;
private int count;
void Update() {
}
void start ()
{
count = 0;
SetCountText ();
WinText.text = "";
}
void FixedUpdate ()
{
}
void OnTriggerEnter(Collider other)
{
{
if (other.gameObject.tag == "pickup")
{
other.gameObject.SetActive (false);
count = count + 1;
SetCountText ();
}
if(other.gameObject.tag == "WinPad")
{
if(count >= 7)
other.renderer.enabled = true;
}
}
}
void SetCountText ()
{
CountText.text = "Diamonds " + count.ToString ();
if(count >= 7)
{
WinText.text = "Portal Open";
animation.Play("spawn");
}
}
}
Comment
Answer by unimechanic · Oct 07, 2014 at 04:23 PM
Debug your scripts in order to find the problem:
http://unity3d.com/learn/tutorials/modules/beginner/scripting/monodevelops-debugger