- Home /
Question by
Viking Goblin · Jan 18, 2015 at 10:12 PM ·
collider
Open a door by standing on a button
I am very new to c# I know this is simple I just don't understand what the debugger is trying to tell me: using UnityEngine; using System.Collections;
public class Button : MonoBehaviour {
public GameObject player;
private int count;
public GameObject door;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (count == 1) {
door.transform.position = new Vector3 (0, 50, 0);
}
}
void OnTriggerEnter (Collider other)
{
if (other.gameObject == PlayerInits) {
count++;
}
}
void OnTriggerExit (Collider other)
{
{
if (other.gameObject == player) {
count = Mathf.Max (0, count - 1);
}
}
}
}
Comment
Hi, in your if statement use CompareTag(). Take a look at the following link. http://docs.unity3d.com/ScriptReference/Component.CompareTag.html
You have also to give the objects a tag in the inspector. http://docs.unity3d.com/$$anonymous$$anual/Tags.html
to Owen; I'm going to guess the problem is line 23 GObj = PlayerInts I see no reference/declaration for that
Your answer