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
1
Question by phatpixels · May 26, 2014 at 11:34 AM · animationvariablespeedrandom.range

Variable is not acknowledge...why???? please help

I have this script that works fine without any errors. But its not working as it should. I need the (legacy)animations to increase in speed over time. Time is taken from another script and the debug recognizes it fine, the speed updates in the inspector fine too. But the animations continue at same original speed and i cant understand why. i must be close surely. any hints please? i have spent a week trying to get this. help:)

pragma strict

 var Anims = ["Roll", "Spin"];
 var Model: GameObject;
 var Upspeed = 1;
 var Other : time;
 
 
 
 
 function Update () {
 
 Debug.Log(Other.score);
  
  
  if (Other.score >= 12) {
     Upspeed = 2;
 
 }
  
  Game();
 
 }
 
 
 
 
 function Game () {
 
 
 var random:float = Random.Range(0,2);
 
 if (random ==0){
 
 animation.PlayQueued("Roll").speed = Upspeed;
 
 }
 
 
 if (random ==1){
 
 
 animation.PlayQueued("Spin").speed = Upspeed;
 
 
 }
 }
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by HarshadK · May 26, 2014 at 11:52 AM

Try:

 animation["Spin"].speed = Upspeed;
 animation.PlayQueued("Spin");
Comment
Add comment · Show 5 · 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 phatpixels · May 27, 2014 at 10:09 AM 0
Share

thgankyou. Although this worked ok, it still didnt alter the speed over time unfortunately. Im looking into animationState, i think this might solve it, i'll repost here if i can make it work :)

avatar image HarshadK · May 27, 2014 at 11:21 AM 0
Share

How do you want to achieve this 'alter the speed over time' effect for animation? Could you elaborate?

avatar image phatpixels · May 28, 2014 at 09:51 AM 0
Share

As the timer script counts past 30 seconds for instance, i wish the random animations to double in speed. Then after the game timer reaches say 1 $$anonymous$$ute have the animations increase in speed further more. Just a game that gets harder as time goes along. the timer works fine. and the speed updates in the inspector, but the animations are not affected for some reason. $$anonymous$$y script is above.

avatar image HarshadK · May 28, 2014 at 10:59 AM 0
Share

Check this code:

 if (random ==0){
     animation["Roll"].speed = Upspeed;
     animation["Roll"].wrap$$anonymous$$ode = Wrap$$anonymous$$ode.Once;
     animation.CrossFade("Roll");
 }
 
 if (random ==1){
     animation["Spin"].speed = Upspeed;
     animation["Spin"].wrap$$anonymous$$ode = Wrap$$anonymous$$ode.Once;
     animation.CrossFade("Spin"); 
 }

Also change this float to int in your code from Update():

 var random:float = Random.Range(0,2);

to

 var random:int = Random.Range(0,2);
avatar image phatpixels · May 28, 2014 at 04:37 PM 0
Share

you know its almost there. the animation does speed up now as time goes by, thats great news. Only one thing has changed and thats the animations are randomly playing without finshing their frame cycle. Not playing all the way through before changing to another. i think its the crossFade bit. i think playQueued did the trick earlier. i will try and incorporate this into your new script. thanks for your help so far.

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

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

animation to play faster over time 2 Answers

Float var to control animation speed? 1 Answer

Animation Stop and Stay 1 Answer

Creating an animation with variables? 2 Answers

I am attempting to play an animation in reverse and slow it down, But it only seems to play forwards. 2 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