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
1
Question by OmegaJeff · Nov 18, 2015 at 08:24 PM · animatortransitiongetbuttondown

Animator Transition Sometimes Misses Single Frame Inputs

I have a HeroInput class that checks for tapping, holding or double tapping buttons. The checks are all done through Update. I've debugged with print to check that the inputs are being picked up correctly by that script.

However, the jump input seems to be getting inconsistently missed by my animator.

I use 'GetButtonDown' to find the specific frame to play the animation and apply the upward velocity. The velocities are being applied correctly by my HeroPhysics script, the character is lifting off. However, the Animator is failing to play the jump animation about 1 in 20 times.

I've checked print to confirm that jInput is set to 1 for only one update frame, so I can only assume that somehow the Animator is not getting an update on that frame.

Any ideas on how to fix this without holding jInput at 1 an extra frame or two? I'm still new to this so I won't be surprised if I'm totally wrong about what's happening.

Here is the relevant bit of script...

 void Update ()
     {
         Animator anim = GetComponent<Animator>();
         //Jump Input
         if (Input.GetButtonUp("Jump")) //Stop Jump&Flight
         {
             jInput = 0;
         }
         if (Input.GetButton("Jump"))
         {
             if (Input.GetButtonDown("Jump"))
             {
                 if (jCount == 1) //Fly
                 {
                     jInput = 3;
                     jCooler = 0.25f;
                     jCount = 2;
                 }
                 else //Jump
                 {
                     jInput = 1;
                     jCooler = 0.25f;
                     jCount = 1;
                 }
             }
             else
             {
                 jInput = 2;
             }
         }
         //jCooler Reset
         if (jCooler > 0)
         {
             jCooler -= 1 * Time.deltaTime;
             if (jCooler < 0)
             {
                 jCooler = 0;
             }
         }
         else
         {
             jCount = 0;
         }
         //Set animator param
         anim.SetInteger("jInput", jInput);
     }
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
1
Best Answer

Answer by OmegaJeff · Nov 18, 2015 at 09:25 PM

I'm an idiot.

I initially set up the Animator following this tutorial: https://unity3d.com/learn/tutorials/modules/beginner/2d/2d-controllers?playlist=17093

It's a great tutorial, but it has you set up the Animator's update mode to Animate Physics. That means it only updates animation params during physics calls and fixed update.

So, to anyone else having this problem, if you want to update animation params during Update, make sure your Animator's update mode is set to normal.

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 NoQuarter2501 · Jul 25, 2018 at 03:38 AM 0
Share

I was having the same issue. So, from one idiot to another; Thanks!!

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

36 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

Related Questions

How do I show "Duration in" and "Duration out" for the transition graph in the inspector window 0 Answers

Mecanim: 2-step transitions in a single update (skip intermediate state) 0 Answers

Why does my Animator not switching states? 0 Answers

Unity Bug UnityEditor.Editorwindow Close when trying to assign an Animator condition 1 Answer

Prevent Colliders animating between animation states or transition the colliders instantly 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