- Home /
Question by
haroonalam · Dec 28, 2011 at 03:33 AM ·
c#gameobject
Null Reference Exception Error(Solved)
Hey, I am getting "NullReferenceException: Object reference not set to an instance of an object", I dont know what is wrong in my code:
I have a class "EnemyInfo" as
public class EnemyInfo {
public GameObject enemyObject;
}
In another class "Enemies" I am using it like this:
public class Enemies : MonoBehaviour {
public static List<GameObject> gos;
public static List<EnemyInfo> gosN = new List<EnemyInfo>();
void FixedUpdate() {
gos = new List<GameObject>(GameObject.FindGameObjectsWithTag("enemy"));
gosN.Add(new EnemyInfo()) //Solved
gosN[0].enemyObject = gos[0].gameObject //here I am getting error, dont know y :S
}
}
Comment
Your answer
Follow this Question
Related Questions
C# Check If Gameobject is within Collider 1 Answer
NPC Class looking for help 1 Answer
Player instantiates Backwords 0 Answers
C# Rotate More than Two GameObjects 1 Answer
C# Array of OtherArray's Meshes 1 Answer