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 /
avatar image
2
Question by Jeff-Rosenberg · Oct 21, 2015 at 09:04 AM · triggermecanimtimetransitionsexit

Exit Mecanim State After Exit Time Or With Interruption And Exit Time

I have a simple test animator controller for variable jumps in a 2d platformer using root motion. My problem is that I have a jump state which will exit to a Jump Cap state that kills the player's upward velocity and then returns to idle (I'll be replacing the Jump Cap state with a StateMachineBehaviour script attached to the Jump state).

alt text

The Jump state should exit either when it plays all the way through (exit time of 1) or when it gets a Jump Cancel trigger. The Jump Cancel should exit the state early, but still have an exit time of 0.5 or whatever value so I can set a minimum jump.

I have 2 transitions exiting the Jump state: alt text

The issue I'm running in to is that what actually happens is that I can tap the jump key and do a minimum jump if I release the jump key and send the Jump Cancel trigger before the exit time for the Jump Cancel transition. I end up with either a minimum jump or a maximum jump, but not anything in between.

Basically, the Jump Cancel transition only works if it receives the trigger before the exit time. If it gets the trigger after the exit time it doesn't do anything, and this isn't what I need.

If I disable the exit time for the Jump Cancel transition it allows me to do a variable jump how I want, but it doesn't allow me to jump at least a minimum amount before exiting.

state-machine.png (18.8 kB)
jump-transitions.png (47.5 kB)
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
5
Best Answer

Answer by Jeff-Rosenberg · Oct 21, 2015 at 07:48 PM

Seem to have found a solution from this thread: http://forum.unity3d.com/threads/mecanim-exit-time-transition-with-additional-condition.243856/

I created a script called SetNormalizedTime:

 public class SetNormalizedTime : StateMachineBehaviour 
 {
     [SerializeField] private string targetParameter = "Normalized Time";
 
     public override void OnStateUpdate (Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
     {
         animator.SetFloat(targetParameter, stateInfo.normalizedTime);
     }
 }
 
 

This script is attached to my Jump state and feeds the state's normalizedTime back into the Animator. Then I turn off Exit Time for my Jump Cancel transition and add NormalizedTime as a float parameter. I can then exit when the normalized time is greater than a percentage of the animation.

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

32 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

Related Questions

Can I make "has exit time" in the animator disabled by default? 0 Answers

Get time when the animation starts in Animator Controller 1 Answer

How to end an animator animation using time? 0 Answers

Previewing Mecanim Transitions from a Blend Tree 0 Answers

Mecanim transition condition can't have both bool and trigger? 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