Hi guys,
I have imported a few characters in my scene but i can not disable or enable them by code.
I have tried more ways but i can not solve them.
Could you guide me?
I have tagged each images to “Fly1”,“Fly2”,Fly3",“Fly4”.
I want on each frame disable fly1 then enable fly2 then disable fly2 then enable fly3 then disable fly3 then enable fly4 again from the first start to disable and enable each images(character).
Errors: link text link text
Thanks
using UnityEngine;
using System.Collections;
public class animationsBirds : MonoBehaviour {
public static int frameCounter =1;
GameObject gos1;
GameObject gos2 = GameObject.FindGameObjectWithTag("Fly2");
GameObject gos3 = GameObject.FindGameObjectWithTag("Fly3");
GameObject gos4 = GameObject.FindGameObjectWithTag("Fly4");
// Use this for initialization
void Start () {
gos1 = GameObject.FindGameObjectWithTag("Fly1"); }
// Update is called once per frame
void Update () {
while (true) {
Debug.Log (frameCounter);
if (frameCounter == 1) {
gos1.SetActive (false);
gos2.SetActive (true);
} else if (frameCounter == 2) {
gos2.SetActive (false);
gos3.SetActive (true);
} else if (frameCounter == 3) {
gos3.SetActive (false);
gos4.SetActive (true);
} else if (frameCounter == 4) {
gos4.SetActive (false);
gos1.SetActive (true);
}
frameCounter++;
if (frameCounter <= 5) {
frameCounter = 0;
}
}
}
}