- Home /
Button Calling Animation, but also change Scene after some clicks
Hello! I am new in Unity, maybe 2 weeks. before we begin I apologize for my bad English.
so, I made a CPR tutorial with some animation. I put a button in the middle of the chest image (so it will trigger CPR animation, you cant trigger it by clicking on the head).
here is the problem. I already called CPR animation, and it back into the previous scene. (as I hoped.) I want after 30x click, we move into a completely new scene. so I put 2nd script in my button (1 script for navigating to CPR animation earlier) but it didn't work. if I use this script in a completely new button, it work. can someone explain where I did it wrong? thanks for the time.
Answer by rh_galaxy · Dec 20, 2021 at 03:01 AM
When you switch to a new scene everything is reset to its original state in that scene. Think about if you really need to switch to a new scene, maybe you can do it by just changing something in a script. I haven't worked with animations so I don't know about that but I still think you shouldn't change the scene if most of it is the same in the new scene. What was it that didn't work?
Yep, about that "reset to its original state", I just realized it. Basically, I put a condition in my button when it was clicked 30x, it will go into the next scene, but it never reached 30x since it was resetting again and again. I need to do both 1st and 2nd animation in 1st scene, but how?
oh btw now I was on another side of the problem. I can do click the button 30 times, and change the scene, but 2nd animation not work. ugh.
Answer by 7364ypk · Jan 02 at 11:33 AM
I got this problem solved a few weeks ago. So here's what I did. 1. I made 1 animation in a scene, and put a button on top of it. 2. this animation has an animation and animator menu, let's note it first 3. I made a counter++ script (for counting button click, ex: if counter>=15 so after 15 clicks it will change scene). this solved first problem, where we can move into next scene after some amount of clicks. 4. for 2nd problem, I drag 2nd animation (which played when the button clicked) to 1st animation animator windows. here I put trigger, when animation 1 played (loop) and the trigger is on (which I connected with button) it will play 2nd animation, for once. and then back to 1st animation. 5. Thank God I managed to finish this problem.
Your answer
![](https://koobas.hobune.stream/wayback/20220613050742im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
after click a GUI button from Menu to Game there are two screens 1 Answer
Is it possible to put a world space UI onto an instantiated object? 1 Answer
Can't instantiate "scene objects" [Unity Mirror Multiplayer] 0 Answers
Go to next scene when correct answer 3 Answers
10 levels in a 1 scene ? 2 Answers