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 L_K_M · Sep 02, 2015 at 05:36 PM · animationanimatortransitionstuck

Animation gets stuck halfway through (Unity 5)

Short version: I'm trying to play a simple animation that rotates a soccer player 360° around the z axis. This works about half the time, but the other half, the player gets stuck halfway through, and the animation stops prematurely.

In this simple soccer game, the player is either running, standing around, or doing a bicycle kick. Here's the animation state machine:

alt text

The transitions seem to work fine, the running animation plays when the player runs, stops when he stops, and when I hit the bicycle kick button, the bicycle kick animation triggers. The problem occurs during the bicycle kick animation.

This is the transition back from bicycle kick to idle:

!

This is the only transition going out of the bicycle kick state.

The animation is supposed to play once, then immediately go back to the idle animation and, if the player is running, continue to isRunning. I'm triggering transitions like this:

     if (!animator.GetCurrentAnimatorStateInfo(0).IsName(animationName)) {
         animator.SetTrigger(animationName);
     }

The idle animation is completely empty.

The bicycle kick animation sets the player's z-rotation to -360 degrees at the beginning, and then rotates him back to 0 degrees:

alt text

The player that's being rotated looks like this:

alt text

The reason why there's a Rotatable GameObject containing a Direction GameObject containing the actual sprites is that I'm using Rotatable to do the bicycle kick animation, and I'm using Direction to turn the player in the direction he's running.

(I also intend to use these two GameObjects to manipulate the pivot point for the animation, by moving one down and the other one up by the same distance.)

All of this works perfectly about 50% of the time. The remaining 50% of the time, the animation triggers fine, but then gets stuck midway through. Here's an animated gif showing the effect:

alt text

(At the moment, the player rotates "into the ground", and I intend to also make him jump at the same time by increasing the y velocity, so it looks like a real bicycle kick, but I'm trying to remove all factors that could have an impact on the animation, so that's not happening in the gif. At any rate, jumping did not help; the problem occurs regardless of whether the player rotates "into the ground" or not.)

Any hints would be hugely appreciated.

Comment
Add comment · Show 2
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 pwego · Sep 02, 2015 at 07:22 PM 0
Share

Are you using edge colliders at all?

avatar image L_K_M · Sep 02, 2015 at 08:18 PM 0
Share

@pwego No, I'm using sphere colliders and box colliders, no edge colliders.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by L_K_M · Sep 03, 2015 at 07:51 PM

I have now figured out what triggers the problem. Like outlined above, I have two nested GameObjects, one that does the animation (Rotatable), and another one that turns the player into the correct direction based on whether he's running to the left or to the right (Direction).

alt text

i change the Direction GameObject's direction programmatically, e.g. like this:

 rotation = new Vector3(0f, 180f, 0f);
 direction.transform.eulerAngles = rotation;

This is what seems to interrupt the animation.

I don't understand why it does so, since the animation occurs in a different GameObject, but at least now I have a starting point for trying to figure out how to fix this problem. I guess I should use animations for turning the player, but turning and doing other animations are completely orthogonal things that should happen independently of each other.

Addendum: Using direction.transform.Rotate instead of direction.transform.eulerAngles seems to have fixed the problem.

 Vector3 rotation = new Vector3(0f, 180f, 0f);
 direction.transform.Rotate (rotation);


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

Answer by insoluzioni · Feb 17, 2021 at 06:27 PM

I was facing a similar issue but my problem was different. I had a Animator controller attached to the parent GameObject and another Animator attached to the child where both performed transform animations.

The parent Animator can animate any of their child elements, so it's not good having different animators among different Hierarchies.

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

29 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

Related Questions

Animation Running Game 0 Answers

Kick bool being blocked by Ground bool 0 Answers

Do not execute an animation event. 0 Answers

Animation won't transition from Idle 0 Answers

How can i check if a transition from animation to animation has finished? 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