Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 GameEverything · Apr 14, 2018 at 09:53 PM · animationrotationspriterotation axispivot-point

Animated Sprite Rotating Around It's Own Axis Instead Of Parent's Using Script. Details Provided.

Hi, everyone!

My problem is probably very simple. I have a heavily animated sprite. The sprite comes in five parts; head, left arm, right arm, left side, and right side. When animating, the character's shoulders move as they should because it's just a series of stationary animated sprites. Now, in order to get his arms to rotate in the correct position, I had to animate a shoulder joint in alignment with each shoulder 'socket', so to speak. So that's the first thing to remember.

Secondly, in order to get the animated arms sprites to align with the new shoulder joint, they had to be 'deparented', parented to a temp sprite, adjusted for any position change (stationary sprites), and then reparented to the shoulder joint.

So, in theory, I figured I'd be able to rotate the shoulder joint and the children (arms) would rotate at that pivot point. Nope. They rotate around their own pivot instead.

If you can think of any solution, a better method of getting the arms aligned and allowing them to rotate, or even an asset from the asset store, please let me know and, as you know, your help is always appreciated.

The code:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 /// <summary>
 /// Add to a joint or child of a joint.  The 
 /// script will then remove the specified child
 /// objects (ChildObjects), change their location
 /// to the specified location (Location), and 
 /// parent them to the temporary parent object 
 /// (TempParent).
 /// </summary>
 
 public class AdjustToJoint : MonoBehaviour
 {
     public Transform[] ChildObjects;
     public Transform TempParent;
     public Vector3 Location;
 
     void Update ()
     {
         foreach (Transform ChildObject in ChildObjects)
         {
             //Parent the child objects to the TempParent.
             ChildObject.SetParent(TempParent);
             //Set the new location.
             ChildObject.localPosition = Location;
             //Reparent the objects.
             ChildObject.SetParent(transform);
         }
     }
 }

And here's a little pic to help you out considering I'm not very, uh, what's the word...

alt text

joint-problem.png (306.8 kB)
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 CraigGraff · Apr 15, 2018 at 04:50 PM 0
Share

Any chance you could post a video or animated gif showing the exact scenario? Also please show where in the hierarchy your animator(s) is/are.

I suspect that you may be suffering from a misunderstanding of how the animator component works with childed objects, but I can't be sure without a better understanding of why you made the script you did.

avatar image GameEverything · Apr 17, 2018 at 10:41 PM 0
Share

Hi! Thanks for the response. I ended up just animating the arms using markers for the shoulders ins$$anonymous$$d. It was much easier than what I was doing. When I went to bed, I was like, "DOH!' because I obviously wasn't thinking clearly. The method you suggested (rotateAround) worked a little better, but it was obviously better to animate the arms according to the shoulder movement and then rerender the arms in 3D Studio without X or Y movement. That's probably how it's supposed to be done anyway. The result is this, and thanks again for your help.

alt text

joint-problem-2.png (40.3 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

241 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 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Sprite rotation with animation (2d project) 0 Answers

Need help with sprite rotation 0 Answers

2D Sprite Animation - Rotate animation on axis 1 Answer

Is there a way to make keyframes of an animation conditional? 1 Answer

Rotate a Sprite Without Using Its Pivot Or Parent GameObject 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