Instantiate not creating new gameobjects?? Help

Hello,

I have some code basically the code calls a public function to instantiate a prefab with a bunch of gameobject animations. For some reasons, I am not sure why multiple objects aren’t created. It works for the first but not the rest. I’m at a lost. Could someone help The function PlayAnimation() is called to instantiate also it calls Stop() before instantiating.

VIvienne

using UnityEngine;
using System.Collections;

public class OrbAnimator : MonoBehaviour
{

	// define prefabs
	public Transform[] AnimationPrefabs;
	private int PlayingCurrentAnimation;
	private bool IsPlaying;
	private float time = 0.0f;

	// Use this for initialization
	void Start ()
	{
	
	}
	// Update is called once per frame
	void Update ()
	{
		if (IsPlaying) {
			time += Time.deltaTime;

			if (time > 5.0f) {
				Stop ();

				time = 0.0f;
				IsPlaying = false;
			}
		}
	}

	public void Stop ()
	{

		GameObject[] gameObjects;

		gameObjects = GameObject.FindGameObjectsWithTag ("OrbAnimations");

		for(var i = 0 ; i < gameObjects.Length ; i ++)
		{
			Destroy(gameObjects[i]);
		}

		Debug.Log ("Destroy");

		time = 0.0f;
		IsPlaying = false;

	}

	// play a animation
	public void PlayAnimation (int AnimationPrefab)
	{
		// if animation more then length then return
		if (AnimationPrefab > AnimationPrefabs.Length || AnimationPrefab < 0) {
			return;
		}

		Stop ();

		Transform prefab;

		//Attach a prefab to the root
		prefab = Instantiate (AnimationPrefabs [AnimationPrefab], new Vector3 (0.0f, -1.0f, 0.0f), new Quaternion (0.0f, 0.0f, 0.0f, 0.0f)) as Transform;

		// Change tag
		prefab.gameObject.tag = "OrbAnimations";

		IsPlaying = true;
	}
}

Are you wanting PlayAnimation to instantiate “AnimationPrefab” copies? Becuase it only instantiating one.
Say you have 10 animationPrefabs all in AnimationPrefabs[ ]. If you call PlayAnimation(6) it will only instntiatiate the 7th (arrays are 0 based) animation.
Do you want PlayAnimation(6) to instantiate 0-6 (7 new objects) ?

Hello

I want to play one animation gameobject from the prefab. When a player gets the another match, I want it to delete the one first created then play another animation.

It seems to make one but not delete and start another. For function calls pOrbAnimation.PlayAnimation() should first call Stop() then Instantiate another.

That’s the way I think it’s written.

Vivienne

I want it to play specific 6. When its either finish deleted or if another Play it’s deleted and another created like specifically 3 etc.