Getting new error when ship crashes after setting up all Wave Timelines & extras

Getting Error below. Will try to figure out but documenting in case I don’t get far; but wow this really took the winds out of my sails.


MissingReferenceException: The object of type ‘GameObject’ has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
CollisionHandler.OnTriggerEnter (UnityEngine.Collider other) (at Assets/Scripts/CollisionHandler.cs:21)


Gameobject that highlights is Player ship when it collides with mountain side.


It points to " deathFX.SetActive(true); " when double click on the error.

Hi Erik,

Check the OnPlayerDeath method. What does it do?

Hi Nina,

OnPlayerDeath is

void OnPlayerDeath()
{
isControlEnabled = false;
}

I rechecked my work watching [100. Enable A Gameobject From C#] video . Seems I had the Check On for PlayerDeathFX prefab inside of Player Ship Prefab and Unchecking PlayerDeathFX has gotten rid of the error and game plays like before. Thanks for checking on me Nina !

I forgot to mention that my PlayerDeathFX also activates when game starts. Ship explodes on starting game but this wasn’t as gamebreaking as the error I received; and this provides no error. in console.

Should I make another post for that Nina?

Is this still an issue or did you fix it as well? I’m asking because this sounds as if “Play On Awake” was ticked in the Particle System, and the game object was enabled in the Hierarchy.

If the Particle System game object is not enabled when the game is not running, it gets enabled during runtime. At least, that’s how it looks in the video. Add Debug.Logs to your code to figure out which method or code block is responsible for the activation.

1 Like

I was able to resolve after trying to do what you mentioned and brain farting about how to go about doing the debug.Log. Your perspective did help me to try something different. It seems my playerships’ position in Scene was too low and Box collider was colliding with terrain collider like it should of.

I had been moving the playerships spacing from the ground using only Timeline before thinking that would be all that is needed. But it seems like correcting it in Scene using the Transform Gizmo resolved it.

Thank you Nina for you help.

Good job on solving the problem. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms