- Home /
main menu animation
what i want to happen is when you click the play button, an animation will play and when its done the frist level will load. if you could script that in java script that would be great!
By animation, do you mean a movie, or some scripted animation, or keyframe animation.... ?
If you could make any effort whatsoever that would be great!
well, i do not know how to do it that is why i asked the question, and @DaveA s car would be in the sceen, and when you click it would drive away, and when that is done the first level loads
Learn something, try something. Come here after if you get stuck. http://unity3d.com/support/documentation/
i tried this: var isQuit = false;
function On$$anonymous$$ouseUp() { if(isQuit) { Application.Quit(); } else { Application.LoadLevel(1); collider.gameObject.animation.Play("move");
}
} ablviosly it didn't work because i do not know how to do it(that is why i asked the question). i got this error: $$anonymous$$issingComponentException: There is no 'Animation' attached to the "New Text" game object, but a script is trying to access it. i want the script to move the car. i look at you link, i tried it by myself, now please just answer my question
Answer by DaveA · Jan 19, 2011 at 02:29 AM
See: http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnGUI.html
It might look something like this (untested)
function OnGUI () {
if (GUI.Button (Rect (10,10,150,100), "olay"))
{
GameObject.Find("myanim").GetComponent(Animation).Play();
yield WaitForSeconds (5); // wait til animation done (probably not a good idea)
Application.LoadLevel("myNextLevel");
}
}
You might need to use a coroutine to do the animation and load next level. You might want the animation to have an event that fires to tell you it's done so you know when to load the next level.
i got this erreor: NullReferenceException textControl+On$$anonymous$$ouseUp$1+$.$$anonymous$$oveNext () (at Assets\textControl.js:19) UnityEngine.GameObject:Send$$anonymous$$essage(String, Object, Send$$anonymous$$essageOptions) UnityEngine.GameObject:Send$$anonymous$$essage(String, Object, Send$$anonymous$$essageOptions) UnityEngine.$$anonymous$$ouseOverPair:Send$$anonymous$$essage(String) UnityEngine.Send$$anonymous$$ouseEvents:DoSend$$anonymous$$ouseEvents()
Your answer
Follow this Question
Related Questions
Can You Animate Main Menu Title? 2 Answers
Playing animation elements not working 2 Answers
Changing two different objects renderer colour 1 Answer
Can the animation editor create local rotational data? 3 Answers
Adding animation clips via script 2 Answers