Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Lystek · Aug 29, 2013 at 09:39 PM · c#animationrotationcoroutineparenting

How can I stop a parented object from resetting its transform when a parent animation play?

Here's my problem : I'm trying to make an object rotate 90 degree over time (blockController). I made an animation that would do such, placed it on an animation component in an empty object(animatron). Now I figured that by parenting the animatron to the blockController, I could have the animatron rotate it and the blockController, then unparent itself and reset its position.

So far it works. What bugs is afterward, when I try to do the operation again : I assumed that I would just have to parent the blockController under the animatron again and that playing the animation would result in the blockController turning an additional 90 degrees.

What happens is that it follows the coordinate of the animation from start again, meaning it resets its rotation and rotate the original 90 degrees. It's where my knowledge gets fuzzy and I'm not sure how and why to fix this... I'm quite the beginner so I still feel I might be missing something basic.

Here are the relevant parts of the code:

     //Function to wait for animation to finish
     IEnumerator waitForAnimation(AnimationClip playingAnim)
     {
         yield return new WaitForSeconds(playingAnim.length);
         blockController.transform.parent = null;
         animatron.transform.position = new Vector3(0,0,0);
     }


             //Place animatron over block position
             animatron.transform.position = blockController.transform.position;
             
             //Parent to block, play anim, unparent after anim is played and reset animatron pos and rot
             blockController.transform.parent = animatron.transform;
             animatron.animation.Play("rotationCwise");
             StartCoroutine (waitForAnimation(animatron.animation["rotationCwise"].clip));
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 DESTRUKTORR · Aug 29, 2013 at 09:42 PM

It's repeating the same animation clip because you didn't record the animation for the additional rotation. That would be a different animation. Animations in Unity start and end at the given angles, positions, scales, etc. that are established when the animation is "recorded."

However, if my knowledge of unity's built-in animation is correct, rotations should be local, so you may want to either rotate the object's parent before the second rotation, or parent a handle game object that can be rotated to the animated object's original parent, and rotate that, after the first animation, and parent the animated object to this new handle object, for the second animation.

Alternatively, you could simply make a second animation clip and play that clip when you wanted the object to rotate a second time.

Yet another option would be to simply not use the animation system whatsoever, and just apply rotation over time, programmatically.

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

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

Flip over an object (smooth transition) 3 Answers

[Animation] Objects rotating in the wrong direction 0 Answers

Clamping look rotation 3d? 0 Answers

iTween Rotation not exact 0 Answers

How do i rotate an object "Once" 1 Answer


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