Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 SilverFang180882 · Feb 23 at 05:07 PM · animationphysicsinputs

Changed to new input system, and now one particular animation won't play...

Hello,

Been practicing Unity by working on a platformer, where the playable character has a melee attack, which triggers an animation where the melee weapon comes out. My game was originally made using Unity's old input system, but I recently decided to adjust it so that it uses the newer one instead.

I finally got done setting up the player character's controls, only to find that the melee attack wasn't working. After a lot of investigation, I discovered that for some reason, it's because the animation isn't activating, for whatever reason. It had worked perfectly fine without a single problem when using the old input system.

The player script is quite long, so I've narrowed down only the parts that involve the melee animation:

 void Update()
     {
         if (anim.GetBool("Melee"))      //If the melee attack animation has finished
         {
             ResetMelee();       //Activates the Reset Melee function
         }
     }
 
 public void MeleeAttack()       //Function for melee attack
     {
         if (!manaSystem.isLow)      //If the player has at least two mana
         {
             melee = true;       //Switch on the melee condition
             anim.SetBool("Melee", true);        //Activates the melee attack animation
             if (!burst)      //If the player isn't in burst mode
                 manaSystem.MinusTwo();      //Reduce the player's mana by 2
         }
     }
 
 public void ResetMelee()        //Function for ending the melee attack
     {
         melee = false;      //Switch off the melee condition
         anim.SetBool("Melee", false);       //End the player's melee attack
     }
 
 public void Melee(InputAction.CallbackContext context)       //Performing a Melee Attack with the new input system
     {
         if (started)        //If the level has started
         {
             if (fromPause)      //If returning to the game from the Pause Menu
             {
                 if (context.performed)     //If any action button is pressed 
                     freezeControls = true;      //Prevent the player character from registering inputs rapidly
                 else        //If no button is being pressed
                 {
                     fromPause = false;      //Recognise that the pause menu is no longer active
                     freezeControls = false;     //Enable player inputs
                 }
             }
 
             if (!freezeControls && !selectMenu && context.performed && !healthSystem.isDead && !stun && !grabbed && !casting && !bonusStage && !shieldActive)        //If the player presses the Melee button
                 MeleeAttack();      //Activates the Melee Attack function
         }
 
     }

If the entire script is needed to further figure this out, please let me know and I'll happily provide it.

I'm currently 100% sure that the only problem is that the animation won't trigger, as I've added Debug.Logs to all parts of the melee attack's process as shown above, and the Debug.Log appeared at every stage, but without the attack animation (even the player's mana is reduced when I press the attack button). I also tried commenting out the "ResetMelee" function, but that didn't make a difference. I even changed anim.SetBool to a different animation, and the other animation worked fine. But when I change it back to melee, I get nothing again. I've truly exhausted everything I can think of as to why the animation no longer plays since I changed the input system.

One other factor I think might be the cause (though another part of me is skeptical), is that I sometimes get a red error message saying: [worker0] tried select unknown importer for id '-2' '00000000000000000000000000000000' However, even when I don't get this message, the animation still doesn't work.

These are the current settings for the animation, and the object's animator: alt text

alt text

One more thing to note: I have a pause menu which, when active, sets the game's speed to 0f (I know this probably isn't the best way to handle pause menus as it's given me difficulties, but I was following a tutorial and managed to make it work as I wanted regardless). Now, I recently fixed a problem where the player's inputs would be read while the game was paused, so that when I unpause it, the character will do all the inputs immediately when the game speed resumes. The reason I'm mentioning this, is because this has been the only way I could get the melee animation to play since changing to the new input system. I would press the attack button while the game is paused (and see that the player's mana decreases), then when I unpause the game, the animation would actually play.

I've since adjusted it so the player inputs are not read while the game is paused, but even then, the melee animation wouldn't play during actual gameplay. Every other animation the character has works fine, except for the melee attack, and I honestly can't see why, especially considering it worked perfectly fine before I changed the input system.

I'm really hoping someone can help me figure this out, because I've exhausted any solutions I can think of myself. It's like the new input system just doesn't like this one particular animation for whatever reason (even though most of the others have the same settings, but play perfectly).

I also think it's worth mentioning that the player object is a prefab, if that makes any difference.

Thanks in advance.

unitymeleeanimmerged2.jpg (102.4 kB)
unitymeleeanimmerged1.jpg (74.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
0

Answer by SilverFang180882 · Mar 04 at 07:46 AM

As a quick update, it turns out I needed the line which switches on the animaton boolean (anim.SetBool("Melee", true);) to the Update function. That's why it worked fine with the old input system (where all the inputs were already in the Update function), but not with the way I'd put the new ones (where the line was in the Callback Context).

I simply made a new statement in the update: if (melee) anim.SetBool("Melee", true);

Seeing as the button input already switches the melee condition on, it triggers the animation from there.

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

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

model 'flinch' or 'jerk' on hit 1 Answer

How do I create a naturally swaying sequence of physics bones for a character? 0 Answers

Starting Timline cutscene without snapping the last animation 1 Answer

Physics with generic root motion 0 Answers

How to make your character lose limbs, either through physics or pre determined animation sequences? 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