• 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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Animation gets stuck halfway through (Unity 5) 2 Answers

Don't know how to end animation of shooting ! (code) Please help ! 0 Answers

Animator consecutive set parameter problem 0 Answers

Kick bool being blocked by Ground bool 0 Answers

Transitioning between walking running idle animations with floats 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges