Instantiate issues

Hello All,

I have opened a new project of a common 2D style for pratice.
However, I have been stucked on some problems,
Please feel free to give help hand if possible.

  1. This is one of the them.I have three prefabs and want to non stop rolling one by one. But I cannot…
    (I drag the following script on the object which I clicked will have animation play and disappear, however, it disappeared, but no new object come out from another pre-set object.)

  var panelA :GameObject;
    var buck : int=1;
    var prefabs : GameObject[];
    var instance : GameObject;
    
    function OnClick(){
    
    animation.Play();
    
    Scoreboard.Score = Scoreboard.Score + buck;
    
    panelA.active=false;
    
    instance.Instantiate(prefabs[Random.Range(0,prefabs.length)]);
    
    Debug.Log("clicked");
        
    }
  1. Can anyone please give some hints or direction, is there a way that the prefab can be re-use( brand new ) after used once? Cuz you can see on the script, Animation of the object was played, I tried animation.Rewind(), but there is no reaction at all.

I am not lazy guy, I have really checked and try much before asking question,as I am very new in code, so PLEASE give a help hand, thx.

Yan

to instantiate

instance = Instantiate(prefabs[Random.Range(0,prefabs.length)]);

To play the animation in reverse order:

gameObject.animation[“animation name”].speed = -1; // speed = 1 for playing in normal order
gameObject.animation[“animation name”].Play();

To start animation from specific time(may b beginning)
gameObject.animation[“animation name”].time = 0.0; // for beginning or any other float value
gameObject.animation[“animation name”].Play();

Hope it helps…