How do i know if a animation is finished or not ? (497158)

hello, guys,
I have now a camera animated here, i need to know how do i deactivate the camera and activate the main camera when the animation is completed, i know that i need to use public gamoject and the things, but i can’t find out if the animation is completed or not :frowning:

how have you animated it?

Can you just check position of camera?

here is my code,

using UnityEngine;
using System.Collections;

public class Cameraswitch : MonoBehaviour {
public GameObject camera1;
	public GameObject camera2;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	   IEnumerator Example() {
        animation.Play();
        yield return new WaitForSeconds(animation.clip.length);
		   
     
   
    }
	
	 
}

so now where should i insert this so it will activate my second camera

       camera1.SetActive(false);
		Debug.Log ("deact");
            camera2.SetActive(true);
 Debug.Log ("act");

please anyone please i am stuck here, jus one to two line of code

i have animated it with the animation thingy, the file name is camera trial 1

which camera’s postion do you need

Try checking animation.isPlaying - Unity - Scripting API: Animation.IsPlaying

In my projects, I set a flag to say that I’ve started an animation. In the Update loop, if the flag is set to true, I call a routine that does:

if (!animation.isPlaying()) {
then I know it’s done
}

Hope this helps.

i have already seen this, but it says some error to me. I use the script in my camera 1 which was animated

thanks it helps now,i was typing the animation name wrong