Hi, im developing a 2d game.
im using this code to invoke three different kind of objects ramdomly to the scene.
#pragma strict
var posible_col = new Array();
var col : GameObject;
function Start()
{
posible_col[0] = GameObject.Find ("f_col_1");
posible_col[1] = GameObject.Find ("f_col_2");
posible_col[2] = GameObject.Find ("f_col_3");
InvokeRepeating("next_col", 2, 3);
}
function next_col ()
{
col = posible_col[Random.Range(0,3)];
Instantiate(col, new Vector2(0 , 9), Quaternion.identity);
}
it works fine, but it does not instantiate a prefab! i can see at the inspector that the object invoked is not a prefab because the cube besides the drop-down tags option, is not blue but green, blue and red (the components of the object invoked are the same as the prefab!).
im using another script that has a OnCollisionEnter2D funtion on it, it works untill i use this one. And the tests i’ve made so far, show that this collision script only works when the colliders are prefabs, i dont know why, but when two of these invoked objects collide, apearly it does not detect the collision and so nothing happens.
the names i used when GameObject.Find are the names of my prefabs, ¿why it instantiate an object?
¿is there something wrong about this code i’ve posted, that could interfere with the other one?
thanks for your help!