- Home /
How to disable a part of a script to avoid replayed camera animations ?
Hi Guys. I'm newbee to javascript,and need help about a script.
There is a box on the table in a square room. And the camera have an animation which zooms to object and also zooms back from object to start position. 2 different animation clips.
I want to play the animationclip on my camera,when i click on the object. So far someone helped me in unity forum how to solve it.
function Update () {
if (Input.GetButtonDown ("Fire1")) {
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray, hit)) {
if ( hit.collider.gameObject.tag == "box3") {
if (!animation.isPlaying) animation.Play ("anim");
if (animation.isPlaying) Debug.Log ("WaitingForTheSignal") ;
else animation.Stop ();
}
}
}
}
My question here is, how can i disable this script after the animation starts.
I click on the object. Camera zooms to object. And when the zoom animation is finished there will be a " back button graphic " on the screen. When the user click on it,the other zoom backwards animation will be played. So between the first animation end and the second animation start, i dont want to have an anmaton play by clckng on the box for avoiding the restarted animation.
I hope could tell my problem with my bad english :)
I will be happy if you help me about this problem.
Thanks...
Your answer
![](https://koobas.hobune.stream/wayback/20220613110513im_/https://answers.unity.com/themes/thub/images/avi.jpg)