- Home /
Camera elements
I have created an animation in with the camera fly in to the menu. When I click Play, I want the camera to fly to an other place but it would do it. This the code I'm using.
var playing : boolean = false;
function OnMouseEnter() { //Change the text color of the test renderer.material.color = Color.red; }
function OnMouseExit() { //Change the text color of the test renderer.material.color = Color.white; }
function OnMouseDown()
{
if (!playing) {
playing = true;
animation.Play ("LevelSelect");
yield WaitForSeconds(animation.clip.length);
playing = false;
}
}
Do I have to do something more?
Answer by Berenger · Jan 27, 2012 at 01:40 AM
First, I'm gonna assume that this script is on the camera. OnMousDown is called when the mouse is over the object the script is attached to, and only if it have a collider. So that's gonna be a problem from the camera. I suggest you use that code :
function Update()
{
if( Input.GetButtonUp(0) ) // mouse left button up
// your code
}
If nothing happens, make sure you don't have a Time.timeScale = 0 somewhere, check if your animation is correct in the animation pannel, verify that your camera does have an animation component with the animation "LevelSelect", and that the name is right.
Does it matter that the camera already had a starting animation?
Answer by dahc2332 · Jan 27, 2012 at 01:57 AM
Thank you for the advice you gave. I'm sorry that I did not make it clear that the script is on the the 3D text(Play), does all that you told me still apply or is it changed now?
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Minimap clicking RTS style feature 3 Answers
camera focus on sphere 1 Answer
Keep character inside camera bounds 1 Answer