Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Dalsia · Sep 24, 2017 at 05:10 AM · animationtimerstate-machineidle animations

Sub-State Machines and 2 Different Idle Animations

I currently have 2 sub-state machines: one for a "docile" state in which I default to a "normal idle" animation, but can also walk and jump, and a second "action" state in which I default to an "alert idle" animation. The action sub-state machine can play attack and cast animations, but also has the ability to walk around and jump (just to be clear, both state machines contain the exact same walk and jump animations). Before transitioning back to docile, all animations in the action state default back to the "alert idle" animation, which has an exit time of 5 seconds.

  • Here's what I'd like to have happen:

I want my player's "normal idle" animation described above to be replaced with the "alert idle" animation whenever my player takes damage or engages in combat for 5 seconds after these events occur. However, I also want my player to be able to walk around or jump, and still go back to the "alert idle" animation if my player has engaged in some form of combat within the past 5 seconds. Imagine this simple scenario:

Player is in "normal idle" stance -->

Player attacks, playing the attack animation -->

Attack animation ends, and player is now standing still in the "alert idle" stance for 3 seconds -->

After these 3 seconds the player walks (the "walk" animation plays) for 1 second -->

The player goes back to standing still, and the "alert idle" animation still plays for 1 more second -->

The player is still standing still, but since 5 seconds have passed the "normal idle" animation resumes.

  • Here's my problem:

I haven't been able to figure out a way to do this because I am not sure how to use the animator to set this up properly. I currently have it so that both sub-state machines have walk and jump animations, but since the action state machine goes back to the "alert idle" stance after walking or jumping, and since the "alert idle" stance has an exit time of 5 seconds, I can perpetually be in the action state machine as long as I keep moving around. If I remove the walk and jump animations and just transition back to the "docile" state machine I can't be alert for the full 5 seconds if I walk or jump (since these animations would default back to the docile state).

Is there a way to make it so that my alert animation will always play for 5 seconds after I'm in combat, but also make that timer reset if, for example, I have 1 second left on the alert timer, but then attack again? I have had this problem for a long time and simply don't understand how to resolve it in Unity.

Can a script be written that forces a switch between states based on a timer?

Thank you in advance for any help you may be able to give me.

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

0 Replies

· Add your reply
  • Sort: 

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

220 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

State transition to Idle, Issues with directional walk to idle anim; 0 Answers

Cycle NPC animations after certain time has passed 0 Answers

Setting transform.eulerAngles doesn't work in a StateMachineBehaviour script 0 Answers

How to play idle animations only when player is idle 0 Answers

how to smoothly transition between animations in the "Any State" state machine. 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