UnassignedReferenceException: The variable LITHIUM of CowKiller has not been assigned.
You probably need to assign the LITHIUM variable of the CowKiller script in the inspector.
UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot) (at C:/BuildAgent/work/d63dfc6385190b60/artifacts/EditorGenerated/UnityEngineObject.cs:74)
UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) (at C:/BuildAgent/work/d63dfc6385190b60/artifacts/EditorGenerated/UnityEngineObject.cs:84)
CowKiller+$spawnCoins$163+$.MoveNext () (at Assets/Standard Assets/Scripts/Enemy/CowKiller.js:311)
That’s the error I’m getting. I’ve double and triple checked that it’s assigned. It is.
I even made a second object, and checked to see
if(Helium == null)
{
Helium = heliumChecker;
}
I added the atoms to the resources folder, and assigned them into the inspector from there.
Same error.
This began to occur when I moved takeDamage into a coroutine, it is the calling function of spawncoins…
function spawnCoins()
{
if(PlayerScores.health > 999)
{
coinsToSpawn += bonusJunk;
}
//while(Spawned > 0)
if(HYDROGEN == null )
{
HYDROGEN = hydrogenChecker ;
}
for(var icount : int = 0; icount < coinsToSpawn;icount++ )
{
elemRand = Random.Range(0,1000);
if(elemRand <= 700)
{
gren = HYDROGEN;
Projectile = HYDROGEN;
}
if(elemRand > 700 && elemRand <= 960)
{
gren = HELIUM;
Projectile = HELIUM;
}
if(elemRand > 960)
{
gren = LITHIUM;
Projectile = LITHIUM;
}
gren = Instantiate(Projectile,Spawn.position,transform.rotation);
gren.transform.position.z = 100;
gren.rigidbody.transform.forward =
Vector3(Random.Range(0,8),Random.Range(0,8),0);
yield WaitForSeconds(0.05);
Spawned--;
}
}
NOW, IF I remove the yield statement, it fixes, but the stuff comes out wrong…
What am I missing