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 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
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 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 ins$$anonymous$$d 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){
             init$$anonymous$$ove = false;
             anim.SetBool("$$anonymous$$oving", 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

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

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

2D Animation does not start 1 Answer

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

2 Different animations with 2 different update modes? 0 Answers

Unity showing "animator" component instead of the "animation" component 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