0
down vote
favorite
so i made 2 scripts and assing it to 2 cubes: cube and cube 1. normaly if you click on cube its set a value so that when you click cube 1 its dispear. if you click cube 1 first it not gonna work. so thats what i tried to make but its do not work and i dont now why
here are my scripts
the script for cube:
using UnityEngine;
using System.Collections;
public class script : MonoBehaviour {
public int test = 0; // make the variable for the value
public void OnMouseDown() // when the user click
{
test = 1; //make the value of test 1
} }
and here is the script for cube 1:
using UnityEngine;
using System.Collections;
public class NewBehaviourScript1 : MonoBehaviour
{
public GameObject a; //make a gameobject
public script script; //make a variable where we put in the script
void OnMouseDown() // when the user click
{
script = a.GetComponent<script>(); // get script
if ( script.test == 1) //test or the variable test in the other script is 1
{
Destroy(gameObject); // destroy the object
}
}
}
can someon please help me