- Home /
Interactive Advert, Animation Problems
I am trying to create an interactive advert in Unity 3.5 with 3 characters, each with an entrance, waiting, question answer and exit animation. There is also buttons on the camera that when pressed trigger an answer animation. The idea is that the characters walk in, wait and after a timer has gone, exit. If a question is asked within the waiting time, then it plays. Once it has played, the waiting animations and timer reset.
However, when I play the scene this message comes up. "MissingComponentException: There is no 'Animation' attached to the "Camera" game object, but a script is trying to access it. You probably need to add a Animation to the game object "Camera". Or your script needs to check if the component is attached before using it. UnityEngine.Animation.Play (System.String animation) Text.OnGUI () (at Assets/Text.js:23)"
This message is on the console and is repeated when I press either of the buttons, along with my characters not moving at all.
Here is the UnityScript/JavaScript code that I am using and making.
// JavaScript var myTimer : float = 10;
function OnGUI () { //Text box GUI.Label ( new Rect (370, 500, 400, 30), "Ask A Question From The List Below");
//Question 1 with box and response animation
if (GUI.Button (Rect (300, 550, 100, 30), "Who Are You?")) {
// This code is executed when the Button is clicked
animation.Play("Lord@InkAnswer1");
}
//Question 2 with box and response animation
if (GUI.Button (Rect (500, 550, 150,30), "Why Are You Here?")) {
// This code is executed when the Button is clicked
animation.Play("Lord@InkAnswer2");
animation.Play("Scrib@ScribbleAnswer2");
animation.Play("Splat@SplatterAnswer2");
}
//Starting animations
animation.Play("scrib@scribbleidle");
animation.Play("Lord@Inkidle");
animation.Play("scrib@splatteridle");
//Waiting animations
animation.Play("scrib@scribblewaiting");
animation.Play("lord@Inkwaiting");
animation.Play("scrib@splatterwaiting");
//timer for waiting animations
if (myTimer > 0) {
myTimer -= Time.deltaTime;
}
//when the timer ends, this animation plays
if (myTimer <=0) {
animation.Play("scrib@scribbleexit");
animation.Play("scrib@splatterexit");
animation.Play("Lord@Inkexit");
}
}
I need the animations to play but I need the buttons to be shown and be interactive when it plays. This is the only script I am using and is attached to the camera at the moment because of the buttons.
I am struggling to figure it out and need immediate help!
Please help me.
Your answer
Follow this Question
Related Questions
Attack While Running 1 Answer
How do i apply animations in javascript? 0 Answers
How to control speed of animation on Unity by a .txt file? 1 Answer
Animation doesn't work 1 Answer