ontriggerexit not working

I have code where when the player leaves a platform, the platform should fall. But instead, the player just falls through the platform instantly. The code is:

void Start () {
     rb = GetComponent<Rigidbody>  ();
 }
 void OnTriggerExit(Collider other){
     if (other.gameObject.CompareTag ("player")){
         rb.useGravity = true;
     }
 }

I have the player set as a trigger and the code is a component of the floor.

Any fixes?

The player shouldn’t be a trigger unless you want it to ignore all colliders and pass through them. Also the platform shouldn’t be a trigger too cause it wouldn’t be possible to walk on it while using physics. So a viable solution would be to create an empty box collider on top of the platform link it to the platform and make it the trigger. And assign that script to the new Trigger Collider

public Rigidbody platformRB;

    void OnTriggerExit(Collider col)
    {
        if(col.gameObject.tag == "Player")
        {
            if (platformRB != null)
                platformRB.useGravity = true;
        }
    }

OR

change on your code the line :

void OnTriggerExit(Collider col)

to:

void OnCollisionExit(Collision col)

And remove any triggers