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
1
Question by Richbk · May 26, 2014 at 02:27 PM · animationunity 2d

Moving a child object during an animation (2D)

I have a 2D character that's set up with an idle animation but I need to be able to rotate a child object (his arm). I also need the rotation to stay in place when playing a walking animation too.

The idea is you can rotate the arm (it has a gun at the end) whilst standing still and also whilst walking. I don't need any transitions as such between the different animations but I need the gun rotation to stay the same.

The problem is that when playing any of the animations the arm cannot be rotated.

The best I can come up with is to set an empty game object on the character where the arm pivot should be then programatically have the arm move to that point.

I was wondering if anyone knows of a better way to do it?

Thanks

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
2
Best Answer

Answer by steakpinball · May 26, 2014 at 06:13 PM

I believe what you are looking for is Animation Layers. Animation layers allow you to override the base animation with another animation. They are commonly used to animate a specific body part without animating the entire body. In your case the base layer would have the idle and walking animation and another layer would have the animations for the arm rotating.

Official documentation https://docs.unity3d.com/Documentation/Manual/AnimationLayers.html

Official Training video https://www.youtube.com/watch?v=fi4O1i8a2Ro

An example in 2D from the live training http://youtu.be/uv2QSvuwIDs?t=35m19s

Comment
Add comment · Show 1 · 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 Richbk · May 27, 2014 at 12:23 PM 0
Share

Thanks for the reply, that's very helpful. $$anonymous$$y issue though is that moving the arm up and down isn't an animation as such, it's done by user input (whilst the up arrow is held, rotate the gun upwards). With that in $$anonymous$$d the angle can vary.

I've managed to get it more or less working by using LastUpdate() and applying a new rotation to the arm every frame. This feels like a bit of a hack though.

Ideally I suppose I'd use animation layers and have an 'Aim' layer set to override that somehow takes an input/rotation.

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

21 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

Related Questions

Unity 2D Topdown Game - Knockback on triggerenter 0 Answers

I have an animated character that's going to ride a bike, but how do I put one leg behind and one leg in front of the bike in Unity 2D? 1 Answer

2D Animation.Play does no effect 1 Answer

Can't get my Unity 2D animation to play properly 1 Answer

issue using OverlapCircle and AnyState in Unity Animator,issue using OverlapCirlce and AnyState in Unity Animator 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