- Home /
This question was
closed Apr 07, 2013 at 06:19 AM by
Loius for the following reason:
Duplicate Question
Question by
turbinator · Apr 07, 2013 at 01:49 AM ·
objecttaglog
Object reference not set to an instance of an object?
Im not sure what is wrong? Here is my code:
var trees: GameObject[];
var bullitPrefab:Transform;
function Start() {
trees = GameObject.FindGameObjectsWithTag("Tree");
}
function Update()
{
if(Input.GetButton("placeLog")) {
for(var tree in trees) {
if(tree == null)
continue;
if(Vector3.Distance(tree.transform.position, transform.position) < 5)
{
Instantiate(bullitPrefab, GameObject.Find("logSpawn").transform.position, Quaternion.Identity);
Destroy(tree);
break;
}
}
}
}
Comment
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How add and mark next object? 0 Answers
Unity3D Pressure Plate request. 3 Answers
How can i delete an item from an array after being used? (So, it won't be repeated) 2 Answers
Creating Object Fog? 1 Answer