Hello! i'm having a weird problem with a script i made, i made a figurine system to watch collectible figurines or trophies in my videogame, in a figurine stand, and my script is used to change the figurine that is being watched, and replaces it for other one, my figurines are gameobjects, and my script works fine but only after the second or third time i press Play, the first time i press play the figurines wont be replaced, they stay there and the next one is loaded, so i have multiple figurines in my stand.
This is the script
#pragma strict
var seleccion: int;
var rotacion = Quaternion.identity;
var posicion:Vector3;
var trofeo: GameObject;
var select1;
var arreglo :GameObject[];
function Start () {
seleccion = 0;
posicion = Vector3.zero;
Instantiate(trofeo,posicion,rotacion);
}
function seleccionar()
{
if(seleccion<0)
{
seleccion = 0;
}
if(seleccion>6)
{
seleccion = 6;
}
Instantiate(arreglo[seleccion],posicion,rotacion);
Destroy (GameObject.FindWithTag("trofeo"));
arreglo[seleccion].gameObject.tag="trofeo";
}
function Update () {
if(Input.GetButtonDown("select"))
{
seleccion += Input.GetAxis("select");
seleccionar();
}
}
i use an array to store all my figurines as gameobjects, as i was saying, this script works fine but only after the second or third time i press play, i don't know why this happens and i need help to solve it, so that it works in the first time i press play, because if i create a build of my game the script wont work, and the stand does not replaces the figurine, because is the first time i press play, i think, anyway, any help would be appreciated. Thanks!
↧