how can i use an array to do multiple animations? c#

Hey there,

I want to make a system where my platform my player stands on changes with the animation I’ve set it up with. I created an array but i get an error, i must confess im still learning arrays as they don’t agree with me. Anyways can anyone suggest what i can do? here is the current code:

using UnityEngine;
using System.Collections;

public class CameraSwitch : MonoBehaviour {
	public GameObject Player;
	private GameObject[] Platform;
	public GameObject Playerobj;
	public AudioClip CameraSWtich;
	
	void Start(){
	Platform = GameObject.FindGameObjectsWithTag("Platform");	
	}
	
	void OnGUI () {
	if(PlayerPrefs.GetInt("ActionBar",0) == 1){
		if(GUI.Button(new Rect(Screen.width /2 -150,Screen.height/2 + 200,50,50),"3D")){
		audio.clip = CameraSWtich;
		audio.Play();
		animation.Play("3dCamera");
		Playerobj.animation.Play("playerout");
		Platform.animation.Play("brick3d");
		TP_Controller tpc = Player.GetComponent<TP_Controller>();
		tpc.thirdDOn = true;
		}
	}
}
}

I think this could possibly solve your problem:

// change this at the top
private GameObject[] Platform;
// to this:
private Animation[] Platform;

// In start change the code to this:
void Start() {
    Platform = GameObject.FindGameObjectsWithTag("Platform") as Animation;
}

Then update the code in your OnGUI function. WARNING this is untested code