I'm creating the platform falling effect by unchecking the isKinematic but I keep getting the error : "MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it. Here is my code:
// Update is called once per frame
void Update()
{
}
private void OnCollisionExit(Collision collision){
if(collision.gameObject.tag == "Player")
{
Fall();
Invoke("Fall", 0.2f); //delay 0.2 s chu y dau va viet thuong
}
}
void Fall(){
GetComponent<Rigidbody>().isKinematic = false;
Destroy(gameObject,1f);
}
Can anyone know how to fix this problem? Thank you.