hi, I am having an error to do with raycasting and adding the object to a list. Here is what I tried:
#pragma strict
var List_1 : Array;
var Object2 : GameObject;
function Start () {
}
function Update () {
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, Mathf.Infinity)) {
if(Input.GetMouseButtonDown(0)){
print(hit.collider.gameObject);
Object2 = hit.collider.gameObject;
List_1.Add(Object2);
for(var test in List_1)
{
Debug.Log(test);
}
}
}
}
And the error I am getting is this:
can someone please help, this is really confusing.