Quantcast
Channel: Questions in topic: "die"
Viewing all articles
Browse latest Browse all 115

Unity Engine GameObject error? help please

$
0
0
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

Viewing all articles
Browse latest Browse all 115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>