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 Michael 12 · Mar 23, 2012 at 12:28 PM · animationanimationsstatesidleidle animations

What's a good way to do multiple Idle animations?

I'm trying to figure out a good way to have it so my player while standing around doing nothing but his idle animation after a few minutes or seconds will perform another idle animation. Maybe even have 3 different animations that will play after each other if the player is idle for a long time. What's the best way to approach this?

Comment
Add comment · Show 1
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 Berenger · Mar 23, 2012 at 06:10 PM 0
Share

Your tags are too specifics. Clic on them and you'll see that you're the only one using them, that's usually not a good sign. Try idle; animation; states

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by farooqaaa · Mar 23, 2012 at 01:06 PM

Here's an idea: (Warning: Untested code)

 var timeForIdle : float = 5f;
 var idleTimer : float;
 var playIdle : boolean;

 funciton Start()
 {
     idleTimer = timeForIdle;
 }
 
 function Update()
 {
     if(noInteractions && !playIdle)
     {
         // Frame rate dependent
         idleTimer -= Time.deltaTime;

         if(idleTimer <= 0)
         {
             idleTimer = 0;
             playIdle = true;
             PlayIdleAnimations();
         }
     }
     else if(!noInteractions)
     {
         idleTimer = timeForIdle;
         playIdle = false;
     }
 }

 function PlayIdleAnimations()
 {
     if(!playIdle)
        return;
 
     animation.CrossFade("idle1");

     yield WaitForSeconds(animation["idle1"].time);

     animation.CrossFade("idle2");

     yield WaitForSeconds(animation["idle2"].time);

     animation.CrossFade("idle3");

     yield WaitForSeconds(animation["idle3"].time);
 }
Comment
Add comment · Show 14 · 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 Michael 12 · Mar 23, 2012 at 01:23 PM 0
Share

looks like that should work I'll test it out and see :)

avatar image Michael 12 · Mar 23, 2012 at 02:09 PM 0
Share

Is this in Java?

avatar image farooqaaa · Mar 23, 2012 at 02:17 PM 0
Share

No, its C#.

avatar image Michael 12 · Mar 23, 2012 at 02:43 PM 0
Share

lol that explains my errors, not really all that good with code to begin with, any chance of a java version of this?

avatar image farooqaaa · Mar 23, 2012 at 03:18 PM 0
Share

I have updated my answer with Javascript. Check it out.

Show more comments
avatar image
0

Answer by Ziron999 · Feb 12, 2014 at 01:56 PM

No definition for noInteractions ??? C# Version:

 float timeForIdle = 5f;
 float idleTimer;
 bool playIdle;
  
 void Start()
 {
     idleTimer = timeForIdle;
 }
  
 void Update()
 {
     if(noInteractions && !playIdle)
     {
         // Frame rate dependent
         idleTimer -= Time.deltaTime;
  
         if(idleTimer <= 0)
         {
             idleTimer = 0;
             playIdle = true;
             PlayIdleAnimations();
         }
     }
     else if(!noInteractions)
     {
         idleTimer = timeForIdle;
         playIdle = false;
     }
 }
  
 void PlayIdleAnimations()
 {
     if(!playIdle)
        return;
  
     animation.CrossFade("idle1");
  
     yield return WaitForSeconds(animation["idle1"].time);
  
     animation.CrossFade("idle2");
  
     yield return WaitForSeconds(animation["idle2"].time);
  
     animation.CrossFade("idle3");
  
     yield return WaitForSeconds(animation["idle3"].time);
 }
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

6 People are following this question.

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

Related Questions

going back to the default state in animator 1 Answer

Idle Animations, Player Walking 0 Answers

Player plays walking animation if I press a and d at the same time while standing still 2 Answers

Why does my animation not play? idle overrules animation? 2 Answers

Animated character making mesh move when idle-animation is playing 1 Answer


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