Tons of errors

Hi!
I have tons of errors (mainly reference errors) in the project.
For example

UnassignedReferenceException: The variable projectile of Enemy has not been assigned.
You probably need to assign the projectile variable of the Enemy script in the inspector.
UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot)
UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:211)
UnityEngine.Object.Instantiate[GameObject] (UnityEngine.GameObject original, Vector3 position, Quaternion rotation) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:285)
Enemy.Fire () (at Assets/Scripts/Enemy.cs:49)
Enemy.CountDownAndShoot () (at Assets/Scripts/Enemy.cs:42)
Enemy.Update () (at Assets/Scripts/Enemy.cs:34)

I managed fixing some of these error by simply saying if (componentVariable != null) but I have no idea about what is this error, it seems like i get it once every frame.

Hi Richard,

Errors tend to cascade, so often a situation can look (and feel) a lot worse than it is,sometimes correcting just one issue will resolve the error cascade.

The first line of the above error is quite useful, it suggests that perhaps you have made a reference in your enemy game object to its projectile game object, perhaps you meant to drag a prefab into an exposed variable in your script component but forgot to?

If you could perhaps provide a bit more information we may be night be able to work through the issue and resolve it.

Perhaps start by providing us with your Enemy.cs script.


See also;

1 Like

Privacy & Terms