so some days ago I've been working on the AI, and it was working pretty well actually, now I was making random enemy spawner in random spawnpoints and I tried, I noticed that there was happenning a really weird problem with an enemy, (the one with less hp, I actually didn't tested the others, but they share the same script)and saw that the death particles didn't stop spawning, and the enemy wasn't getting destroyed(my die() void)
void Die(){
GameObject particlesClone = (GameObject) Instantiate (particles,transform.position,Quaternion.identity);
if(closestPlayer)
GameObject.Find("ScoreManager").GetComponent().score += 1;
Destroy(gameObject);
}
I am getting this awkward error:
NullReferenceException
UnityEngine.GameObject.GetComponent[ScoreManager] () (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/UnityEngineGameObject.cs:27)
EnemyScript.Die () (at Assets/Scripts/AI/EnemyScript.cs:62)
EnemyScript.Update () (at Assets/Scripts/AI/EnemyScript.cs:25)
I have no idea why this is happenning, the only thing that might have cause it was probably moving the project's root folder because I couldn't import fonts (and moving the root folder sometimes fixes it, and it did!) so yeah, help me please!
Thanks in advace
↧