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 iamfilipe · Apr 16, 2015 at 01:42 AM · animationtriggermecanim

Best way of starting an animation based on trigger

For the short version, here is the direct question: Does an idle state, without any animation use system resources while playing? If it does, what is the best way of starting an animation without having that idle state waiting for a trigger to start the animation?

Long Version:

Hello everyone. I started working recently on Unity 5 so I still don't know that much about it. Never used it before too.

I have a scene with a door, and an animation that rotates the door handle. I want to play the animation when the player hits the action key (for now I just used E) near the door. I manage to make this work, but I think it isn't very good in terms of resources. What I did was adding a box collider with trigger and then on a script added the folowing:

 void OnTriggerStay()
 {
     if (Input.GetKeyDown(KeyCode.E))
     {
         anim.SetTrigger("StartRotation");
     }
 }

In the animator I made a "idle" state that does nothing, and then added a transition to the rotating animation, based on that trigger. I unchecked the "Has exit time" checkbox and it seems to work properly. When I press E near the door, the Door Handle rotates instantaneously. What I think it's not good is, the "idle" state is always playing, and I wonder if because of that it isn't wasting resources...

I'm using mecanim though...

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
Best Answer

Answer by lordlycastle · Apr 16, 2015 at 04:09 AM

Unless there are some crazy calculations going on in Idle state you shouldn’t care, because each frame will be printed not matter what. So if it’s just small/no movement, it doesn’t matter; it gives it like look.

If you still want to change default state of animator, you can do so by right clicking a state in the Animator Controller Window(The orange one is the default). Then you can change idle to false from script and it’ll go to default state. Read more about it here

Comment
Add comment · Show 1 · 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 iamfilipe · Apr 16, 2015 at 09:45 AM 0
Share

Thank you for your answer. It isn't doing nothing at all, it is just an empty state without any animation. But it seems such an unclean solution, that's why I asked :/

Well, I tried changing the default state but what happens is that it starts playing the animation even if I don't fire the trigger :/

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

2 People are following this question.

avatar image avatar image

Related Questions

Mecanim Trigger Stays too long true 1 Answer

Totally new noob to mecanim and unity itself - Trigger animation? 0 Answers

Trigger Activated Multiple Times From One Click 2 Answers

Mecanim Trigger getting stuck in 'TRUE' state 9 Answers

Mecanim triggering an animation from object 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