• 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 Genial Idiot · Apr 22, 2015 at 05:30 PM · animationanimatorupdatepositioning

Parent and child repositioning

I have a ladder climbing animation where I tried scripting the player to be placed on the upper platform while the animation takes place at the bottom of the ladder. Everything works fine, except that when the animation is executed in-game, you can see the player's sprite going up and back down quite quickly.

I've tried countless things like: Using an animation event at the beginning of the animation

Repositioning parent and child when the Animator is playing the ladder climbing animation "if(anim.GetCurrentAnimationState(0).IsName("LadderClimb"))"

Having it wait until the end of the frame and then repositioning both. "yield return new WaitForEndOfFrame()"

I can't move the child gameobjects in-game using the movement arrows except when I disable the Animator component, which obviously makes me think that it has to do with the Animator. Any help with this would be hugely appreciated.

Comment

People who like this

0 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 Jessespike · Apr 22, 2015 at 08:47 PM 0
Share

The player is being parented? Don't think you should have to do that. This animation shouldn't be a problem. Seems like a code problem, but can't help you without seeing the code.

avatar image Genial Idiot · Apr 22, 2015 at 11:47 PM 0
Share

The player isn't parented, the player's arms, legs, torso and head are parented to an empty Gameobject as a "vessel" of sorts. I animate the body parts within the vessel. The vessel itself is parented to another empty Gameobject, so that I can move the player's entire body in one go when animating. That way the changed position remains a local position instead of a world position, which makes animations reusable.

![alt text][1] [1]: /storage/temp/45058-player-children.jpg

I've already fixed it, but I find the fix quite inelegant. I've made a sprite of the animation's first frame placed it at the bottom of the ladder and had it activated when the player gets repositioned and have the vessel deactivated and when the animation starts reactivate the vessel and deactivate that sprite's gameobject.

I'd still like to find a proper fix to this, if there is one.

Here's the relevant bits of code, unless you need to look at the whole the script:

 if(transform.position.x == targetPos.x){
             initMove = false;
             anim.SetBool("Moving", false);
 
             if(doubleClicked){
                 climbing = true;
                 facingRight = true;
                 anim.SetTrigger("Ladder");
                 transform.position = new Vector3(1, 6.92f, 0);
                 vessel.SetActive(false);
                 climbFix.SetActive(true);
                 doubleClicked = false;
             }
         }
 
 if(anim.GetCurrentAnimatorStateInfo(0).IsName("LadderClimb")){
             vessel.SetActive(true);
             climbFix.SetActive(false);
         }


 
player-children.jpg (37.2 kB)

0 Replies

  • Sort: 

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

2 Different animations with 2 different update modes? 0 Answers

Unity showing "animator" component instead of the "animation" component 2 Answers

Should we check animation condition in Update or FixedUpdatE? 3 Answers

Best way to - Animation Sync - Multiple gameObjects. 0 Answers

2D Animation does not start 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