Question by 
               rajlds · Oct 31, 2020 at 12:52 PM · 
                c#unity 5booleanontriggerexitoncollisionexit  
              
 
              void OnTriggerExit 3d not working on my script?
Hi I am working On unity from 1 month, i wrote all the script and came with a problem ontriggerexit 3d not working i tried many things nothing give me right result. please help
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class changer : MonoBehaviour
 {
     public void OnCollisionExit(Collision collision)
     {
         if (collision.gameObject)
         {
             Debug.Log("spawning");
             spaw.stopspawner = false;
         }
     }
     public void OnCollisionEnter(Collision collision)
     {
         if (collision.gameObject)
         {
             Debug.Log("spawning");
             spaw.stopspawner = true;
         }
     }
 
     public void OnTriggerExit(Collider other)
     {
         if (other.gameObject.tag == "Player")
         {
             Debug.Log("work");
             spaw.stopspawner = false;
         }
     }
 }
 
               i also tried OncollisionExit it dont work
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class script : MonoBehaviour
 {
     public Transform housepos;
     public Transform deadpos;
     public float speed = 90f;
     public float speed2;
     [HideInInspector]
     public bool mustPartorl;
     public static bool fullstop;
     public Rigidbody rb;
     public Transform groundCheckPos;
     // Start is called before the first frame update
     void Start()
     {
         mustPartorl = true;
     }
 
     // Update is called once per frame
     void Update()
     {
         if (mustPartorl)
         {
             Partor();
         }
     }
     public void Partor()
     {
         rb.velocity = new Vector3(speed2 * Time.fixedDeltaTime, rb.velocity.y);
     }
 
     public void die()
     {
         transform.position = Vector3.MoveTowards(transform.position, deadpos.position, speed * Time.deltaTime);
     }
     public void safe()
     {
         transform.position = Vector3.MoveTowards(transform.position, housepos.position, speed * Time.deltaTime);
     }
     public void OnTriggerEnter(Collider other)
     {
         if(other.gameObject.tag == "stop")
         {
             fullstop = true;
             spaw.stopspawner = true;
         }
         if (other.gameObject.tag == "house")
         {
             Destroy(this.gameObject);
         }
         if (other.gameObject.tag == "lava")
         {
             Destroy(this.gameObject);
         }
     }
     public void OnCollisionEnter(Collision collision)
     {
         if(collision.gameObject.tag == "stop")
         {
             Debug.Log("stop");
             fullstop = true;
             spaw.stopspawner = true;
         }
     }
     public void OnCollisionExit(Collision collision)
     {
         if (collision.gameObject.tag == "stop")
         {
             Debug.Log("spawning");
             fullstop = false;
             spaw.stopspawner = false;
         }
     }
 
 }
 
               so also kept 2 different box colliders at unity 1 with trigger ticked 2 with no trigger ticked thanks in advance and the third script where bool acts
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class spaw : MonoBehaviour
 {
     public float startTimeBTwSpawn;
 
     public float timeBTwSpawn;
 
     public GameObject[] enemies;
     public static bool stopspawner = false;
     public static bool afterspawner = false;
     private void Start()
     {
         
     }
     public void Update()
     {
         if(stopspawner == false)
         {
             Debug.Log("stopspawner = false");
             if (timeBTwSpawn <= 0)
             {
                 int rand = Random.Range(0, enemies.Length);
                 Instantiate(enemies[rand], transform.position, Quaternion.identity);
                 timeBTwSpawn = startTimeBTwSpawn;
             }
             else
             {
                 timeBTwSpawn -= Time.deltaTime;
             }
         }
         if(stopspawner == true)
         {
             Debug.Log("stopspawner = true");
         }
     }
 
 }
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Why does Bool code never work in my C# Script? 1 Answer
How can I make a collider that gives me stat up to stop giving me it? 0 Answers
Rotation Changing Z-Coordinate Value 0 Answers
OnGUI will not show up? 1 Answer
Why isn't my object lerping ? C# 2 Answers