MissingReferenceException: Rigidbody2D has been destroyed

Hey guys fairly noobish to unity. I’m trying to make my character die/disappear on collision. I’ve read some of the other posts and have used Destroy (gameObject); to destroy it, but I get the below error.

“MissingReferenceException: The object of type ‘Rigidbody2D’ has been destroyed but you are still trying to access it.”

Currently my setup in slightly psuedo code is:

void Update() {
    if(key pressed) {
        load level;

        do other stuff as well...

void OnCollisisonEnter2D(Collision2D c) {
    Destroy (gameObject);

So once the collision happens, shouldn’t it be seeking for the press of my button?

Clicking on the error takes me to a fixed update in another class.

When you click the error and it takes you to another line in another script, that is the line where the error was found! Perhaps you are trying to access a rigidbody when it doesn’t exist on the gameObject or maybe the rigidbody component isn’t active in the inspector (although I don’t know if that would make a difference).

The missing reference is basically saying that the component you referenced is missing.
It then says “Rigidbody2D has been destroyed but you are still trying to access it” is pretty self explanitory!

I think the problem is you’re trying to access the component after you have destroyed the gameObject meaning the component doesn’t exist anymore.

**Also if you destroy a gameobject the scripts on it will be destroyed aswell as the gameobject. if the code where you check for input is on the gameObject you destroy then the code wont run because you’ve destroyed it! Try applying the script on an object which won’t be destroyed and ch