• 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
Question by AbePoppy · Nov 21, 2013 at 03:14 PM · movementanimatormecanimresetreset-position

How to reset position of an object after animation

Hi guys, I'm learning how to control objects with Mecanims, and I have a question about the usage of the animator. Maybe how I'm solving the problem is the wrong way, and if there are different solution I'm obviously interested.

I have a animation of a movement on a card object. Card object is contained in a Container object. I need that when I hit a button the card does the animation and, at the animation's end, the Container moves to the final position of the animation.

Now: The animation is activated by bringing the animator to a "Movement" state. After the movement state, the animator makes a natural transition (it just has an Exit time) to another state: Movement_Complete. This other state does not have any animations on it, because is a transition state.

I have a script on the card that each Update() checks if the animators goes in the Movement_Complete state (I use var = cardAnimator.GetCurrentAnimatorStateInfo(0) and then if(var.IsName("Movement")). If it does: it calls a function that sets the position of the Container to the position I want.

Here is the problem: when the Container arrives in this position, the card model transform node is already in the correct position. I think this happens because the transform node is not translated from the animator, BUT the card is still in the position of the last frame of the last animation (the movement one). So the final effect is that the movement animation goes well but as soon I set the final position of the Container, the card gets teleported further.

I tried lots of possible solutions that came to my mind. I think that the fact that there is not another animation in the Completed_movement state, means that the card keeps using the last animated keys until some other keys overwrite the animation. So I create a StandStill animation of 2 frames and I put it in the Complete_Movement state, that works but not well. The problem of this solution is that the card returns to it's correct position, THEN the Update() function checks if the animator has entered in the Complete_Movement state and so it puts the Container in the correct position. So for a (very bad and visibile) frame the card returns to the origin of the animation.

Someone knows how to fix it? Or knows a better solution? Thanks a lot

Comment

People who like this

0 Show 0
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
Best Answer

Answer by infinitypbr · Nov 21, 2013 at 05:58 PM

Make the animation on the card itself non-motion, and make a motion animation for the container. So in essence the container moves (which also moves it's children), and the card simply "rotates" or what ever else, non-movement, it should do.

Comment

People who like this

0 Show 2 · 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 AbePoppy · Nov 29, 2013 at 03:51 PM 0
Share

thanks, I was hoping that there was a system to avoid the usage of two animators.

avatar image AbePoppy · Nov 29, 2013 at 04:52 PM 0
Share

sorry for the late answer. We encountered other bugs and we where solving them. Thanks a lot.

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

17 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

Related Questions

Rotation with mouse instantly resets 1 Answer

Can i use mecanim animator while using legacy? 1 Answer

root motion on in place animation 0 Answers

Make a third person controller advanced using animation 0 Answers

Blending Animator Animations with Ragdoll 2 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