I`ve tryed different methods, but none of them worked for some reason. What am i doing wrong?
Script 1:
public class FloorProtector : MonoBehaviour {
GameObject temp = GameObject.Find("Cube");
void Start() {
BoxBehavior script = temp.GetComponent<BoxBehavior>();
script.isColliding = true;//testing if it works or not
}
…
Script 2:
public class BoxBehavior : MonoBehaviour
{
public bool isColliding = false;
I think the problem is that you tried to find the Cube in the variables. You shoud allways use the GameObject.Find() in the Start() and in the Update()
so the code is:
public class FloorProtector : MonoBehaviour {
GameObject temp;
void Start() {
temp = GameObject.Find("Cube");
BoxBehavior script = temp.GetComponent<BoxBehavior>();
script.isColliding = true;//testing if it works or not
}