This code used to work before, but now it doesn't.

using UnityEngine;
using System.Collections;

public class Water_Init : MonoBehaviour {
    void OnTriggerEnter(Collider fall) {
        if (fall.gameObject.name == "Player") {
            Destroy(fall);
        }
    }  
}

Yes, this is how player is named “Player”, collider is activated and instead of eliminating “Player” I get this message error: “Can’t remove CharacterController because CharacterMotor (Script) depends on it”.

Because ‘fall’ is the collider (in this case a character controller), and you are trying to destroy ‘fall’
Maybe you wanted to destroy ‘fall.gameObject’?

2 Likes