// Update is called once per frame void Update() { if (plate == null) { Debug.Log("Error:" + name + " has no plate."); return; } if (previous != plateScript.isActivated()) { switchState(); } previous = plateScript.isActivated(); }
// Use this for initialization void Start() { if (gameObject.GetComponent <Renderer>() != null) { rend = gameObject.GetComponent <Renderer>(); rend.enabled = present; } if (gameObject.GetComponent <Collider>() != null) { cldr = gameObject.GetComponent <Collider>(); cldr.enabled = present; } if (gameObject.GetComponent <Rigidbody>() != null) { rb = gameObject.GetComponent <Rigidbody>(); if (present) { rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ; } else { rb.constraints = RigidbodyConstraints.FreezeAll; } } if (plate == null) { Debug.Log("Error:" + name + " has no plate."); return; } plateScript = plate.GetComponent <PlateBehavior>(); previous = plateScript.isActivated(); }