- Home /
Question by
Jack423 · Jun 04, 2014 at 02:24 AM ·
camera rotateanimation controller
Camera Rotate animation
In my menu, I have to animations to rotate the camera to a different part of the menu (i.e options or credits). But it seems like the animations are not playing when I click the buttons. Also, when I tried to make an Animation Controller for the animations, it would just keep playing them over again and there was no control. Is there a way to control this in scripting? How? Also you can take a look at my script to see what I am doing wrong (I am using NGUI and the function OnButtonClick()
function is correct).
#pragma strict
var button = "play"; //user types in value for different types of buttons in the menu
var LevelToLoad = 0;
//Leave this option blank if you are loading the credits or something else in the same scene.
var MainCamera : Animation;
var MenuPannel : GameObject;
var FaderBack : GameObject;
var FaderFront : GameObject;
var isFaderFrontActive = true;
var isFaderBackActive = false;
function OnButtonClick()
{
MainCamera = GetComponent("Animation");
if(button == "play")
{
Application.LoadLevel(LevelToLoad);
}
if(button == "exit")
{
Application.Quit();
}
if(button == "credits")
{
animation.Play("CameraRotate");
MenuPannel.SetActive(false);
Destroy(FaderFront);
if(isFaderBackActive == false)
{
Instantiate(FaderBack);
isFaderBackActive = true;
}
}
if(button == "back")
{
animation.Play("CameraRotateBack");
MenuPannel.SetActive(true);
Instantiate(FaderFront);
Destroy(FaderBack);
isFaderBackActive = false;
}
}
Comment