Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by captainkrisu · Mar 14, 2015 at 01:42 AM · animationfreezebackwards

How do I make animation go to end frame, and back to start?

Okay, so... 'Detailed' Question.

I'm trying to make Animation go to end frame (40) and when UI button is pressed, go back to start (0).

Now, I'm trying to use

 GetComponent.<Animation>()["Animation"].time >= 1.5|| GetComponent.<Animation>()["Animation"].time <=0.0)
 {
 GetComponent.<Animation>()["Animation"].speed = 0;
 }

Its in FixedUpdate BTW

The problem is that if time goes more than 1.5, or below 0.0 too much. Making the animation speed 1 again doesn't work, because it is stopped instantly by this.

I'll show it by video. It happens around 01:15 minutes

YoutubeVideo

It may not seem that big a problem, but it happens randomly, and may be more common on slower PC's.

Help?

Seems like I have to just post the whole code. Its easier for you to understand.

 #pragma strict
 
 private var backward: int = 0;
 
 var MainCam: Animation;
 var Mainmenu: Animation;
 var NewGameMenu: Animation;
 
 function Play()
 {
 MainCam.GetComponent.<Animation>()["MainMenuCamRotate"].speed = 1;
 Mainmenu.GetComponent.<Animation>()["MainMenu1"].speed = 1;
 NewGameMenu.GetComponent.<Animation>()["NewGameMenu1"].speed = 1;
 MainCam.GetComponent.<Animation>().Play();
 Mainmenu.GetComponent.<Animation>().Play();
 NewGameMenu.GetComponent.<Animation>().Play();
 }
 
 function Stop()
 {
 backward = 1;
 }
 
 function Update(){
 if(backward==1)
 {
 MainCam.GetComponent.<Animation>()["MainMenuCamRotate"].speed = -1;
 Mainmenu.GetComponent.<Animation>()["MainMenu1"].speed = -1;
 NewGameMenu.GetComponent.<Animation>()["NewGameMenu1"].speed = -1;
 backward = 0;
 }
 }
 
 function FixedUpdate()
 {
 
 if(MainCam.GetComponent.<Animation>()["MainMenuCamRotate"].time >= 1.5 || MainCam.GetComponent.<Animation>()["MainMenuCamRotate"].time <=-0.1)
 {
 MainCam.GetComponent.<Animation>()["MainMenuCamRotate"].speed = 0;
 Mainmenu.GetComponent.<Animation>()["MainMenu1"].speed = 0;
 NewGameMenu.GetComponent.<Animation>()["NewGameMenu1"].speed = 0;
 }
 }

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image meat5000 ♦ · Mar 13, 2015 at 06:29 PM 0
Share

For the Legacy system this is a common question. Try Ping-Pong. You can also change 1 to -1 speed.

avatar image captainkrisu · Mar 13, 2015 at 10:10 PM 0
Share

Ill try Ping-Pong.

E: Didn't work. It just bounces

avatar image meat5000 ♦ · Mar 14, 2015 at 01:10 AM 0
Share

Oh you want to rewind it?

avatar image captainkrisu · Mar 14, 2015 at 09:12 AM 0
Share

I'll explain again, this time I'll try.

I'm making $$anonymous$$ain $$anonymous$$enu, and when you click New Game ui button, 3 animations happen, 1. Camera rotates 180 degrees and shows planet. 2. $$anonymous$$ain $$anonymous$$enu slides to the right and disappears. 3. New Game options come from the right.

The New Game options has back button, as you may saw on the video. When you press the Back button, it rewinds, plays the animations back to start.

I hope that is more clear than first, haven't done English in a while.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Lilbob · Mar 14, 2015 at 03:47 PM

Try AnimationState.normalizedTime = 1; 0 will be the first frame, 1 will be the last, 0.5 the middle. Then use AnimationState.time = 0 to reset the animation.

Cheers

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image captainkrisu · Mar 15, 2015 at 05:13 PM 0
Share

Thanks for answers Lilbob and meat5000, they didn't work really but gave me idea. Thank you.

avatar image captainkrisu · Mar 15, 2015 at 09:04 PM 0
Share

Nothing seems to work. I'll just add button to reset animation if it breaks for some reason.

Thanks for answers meat5000 and Lilbob, they gave me idea how else I could do this.

avatar image
0

Answer by meat5000 · Mar 15, 2015 at 09:14 PM

I still dont understand how you cant get this to work ;)

You can also change 1 to -1 speed.

http://docs.unity3d.com/ScriptReference/AnimationState-speed.html

(Or to rewind without playing, this)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

web build unity (3.5.0) crashes... 1 Answer

Playing Queued Animation Freezes Unity, Causes Error 0 Answers

Animations aren't playing in reverse. 0 Answers

Button to play animation in reverse 1 Answer

Game freeze while passing from Idle to any other animation...? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges