title: "Object reference" needed in script
body: <p>I am currently working on a foxes &amp; rabbits simulation, and I am completely stuck on "breeding". </p>
  
  <p>The way I have built the simulation, three scripts are used; “TheGame”, “FoxScript” and “RabbitScript. Since the foxes and rabbits are essentially the same, we can reduce these three to two scripts; “RabbitScript” and “TheGame”. The RabbitScript is attached to the respective prefab; the “rabbitPrefab”, whereas TheGame is attached to an empty GameObject. </p>
  
  <p>TheGame instantiates a number of RabbitPrefabs, which then move, age and breed. Since the build is supposed to collect and present data at a later stage, the rabbits are included in a list as well as being counted. This list is found in the main script, and when the rabbits breed, the offspring needs to be included in this list as well as adding to the counter. </p>
  
  <p>I have tried instantiating a primitive with this method, and it works. </p>
  
  <p>The Breed function in the script attached to the rabbits: </p>
  
  <pre><code>void Breed(){   
      float p = Random.Range (0.0f, 1.0f); 
      if (p &lt; probability2breed) {        
              position = gameObject.transform.position;
              TheGame.BreedRabbit(position);  
      }
  }
  </code></pre>
  
  <p>And the BreedRabbit method in TheGame script: </p>
  
  <pre><code>public static void BreedRabbit(Vector3 position)  {
      GameObject rabbit = Instantiate(RabbitPrefab) as GameObject; 
      rabbit.transform.position = new Vector3(position); 
      Rigidbody gameObjectsRigidBody = rabbit.AddComponent&lt;Rigidbody&gt;(); 
      rabbit.GetComponent&lt;Rigidbody&gt;().useGravity = false;
      rabbit.name = "Rabbit#:" + rabbitCount; 
      rabbit.tag = "rabbittag"; 
      rabbits.Add(rabbit); 
      rabbitCount++;
  } 
  </code></pre>
  
  <p>NOTES: (I figure a lot of this code seems pointless, so to answer any questions about that beforehand: I use collider to handle interactions between the agents involved, and to my understanding this calls for a rigidbody. With rigidbody they started falling, even without mass, so I had to turn of gravity. The tags are to my understanding needed for collision handlig as well.I could probably skip the count and just count the list, but this shouldn't matter now)</p>
  
  <p>It keeps asking for an object reference , and I just can't figure out how this can be solved?</p>
  
  <p>THe error message: "an object reference is required for the nonstatic field method or property"</p>