basically i have a script to stream terrains is verry simple Code (CSharp): void OnTriggerEnter(Collider col) { if (col.tag == "Loader") { this.gameObject.transform.GetChild(0).gameObject.SetActive(true); } } void OnTriggerExit(Collider col) { if (col.tag == "Loader") { this.gameObject.transform.GetChild(0).gameObject.SetActive(false); } } it worked normally but yesterday a random error just pop up: Destroying GameObjects immediately is not permitted during physics trigger/contact, animation event callbacks or OnValidate. You must use Destroy instead. UnityEngine.GameObject:SetActive(Boolean) Streamer:OnTriggerExit(Collider) (at Assets/Scripts/Streamer.cs:18) the line 18 is : Code (CSharp): this.gameObject.transform.GetChild(0).gameObject.SetActive(false); can someone tell me why is this happening ?
Perhaps you have a DestroyImmediate call inside an OnDisable event in a script attached to some child? Just guessing...
not really just the terrain from unity with no scripts attached no more gameobjects just the terrain.
I am having the same problem. All I am doing is hiding Terrains, AI and objects that are faraway based on player's postion. Code (CSharp): private void OnTriggerEnter(Collider other) { if ((DetectLayer & 1 << other.gameObject.layer) == 1 << other.gameObject.layer) { foreach (Transform sec in SectionsHide) { sec.gameObject.SetActive(false); } foreach (Transform sec in SectionsUnHide) { sec.gameObject.SetActive(true); } } } I keep getting this error: Destroying GameObjects immediately is not permitted during physics trigger/contact, animation event callbacks or OnValidate. You must use Destroy instead. UnityEngine.GameObject:SetActive(Boolean)