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
2
Question by Ananta · Jun 30, 2011 at 06:05 AM · transformscalebone

Scaling width/height of a character's head/body

I want to scale width/height of my character's head/body mutually independently.

But due to the bone structure as shown below, When scale the body(Hips bone), the head is also scaled.

 Hips
  Pelvis
   ...
  Spine
   ...
   Head


So my code is like this and it seemed to be worked.

 void LateUpdate()
 {
     HipsTransform.localScale = new Vector3(hipsWScale, hipsHScale, hipsWScale);
     HeadTransform.localScale = new Vector3(headWScale / hipsWScale, headHScale / hipsHScale, headWScale / hipsWScale);
 }

But rotating the spine(for animation), the head is skewed. This is my problem.

alt text

I found that this is common mathematical issue but I want to know how to solve it.

Unity's transform matrix and global scale is read only. How should I do?

Is there any way to scale width/height of my character's head/body mutually independently?

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

5 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by sneftel · Jul 11, 2011 at 01:56 PM

Non-uniform scaling CAN be done for skeletons without causing skew. In order for it to work, though, you'll need to invert the scale in the next node down. There must be one of these auxiliary nodes for each child of the original bone which you want to scale, and it must have the translation from the original node, the inverted scale, and NO rotation. Suppose you had a character with the following bone structure:

 Hips
   Spine
     LUpperArm
       LForeArm
         LHand
     RUpperArm
       RForeArm
         RHand
     Neck
       Head
   LThigh
     ...

In order for this to work, you'll need auxiliary nodes for LUpperArm, RUpperArm, and Neck:

 Hips
   Spine // Contains non-uniform scale
     LUpperArmAux  // Contains inverse scale of Spine, translation from LUpperArm, and no rotation
       LUpperArm  // Contains no translation
         LForeArm
           LHand
     RUpperArmAux  // Contains inverse scale of Spine, translation from RUpperArm, and no rotation
       RUpperArm  // Contains no translation
         RForeArm
           RHand
     NeckAux  // Contains inverse scale of Spine, translation from Neck, and no rotation
       Neck  // Contains no translation
         Head
   LThigh
     ...

All this, of course, needs to be supported by your animations (by expecting LUpperArm to be a child of LUpperArmAux, for instance). In your animation program, make sure the LUpperArmAux bone has zero length, the LUpperArm node is constrained to have no translation, and the LUpperArmAux bone has its joint limits set to identity. And when you skin your character, make sure to exclude the Aux nodes from affecting vertices.

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 Ananta · Jul 19, 2011 at 07:13 AM 0
Share

Finally I adopt your way and now I can use non-uniform scaling, thanks Ben 12! (Because I don't need to translate bones, I simplified your method.) $$anonymous$$oreover, as Warwick Alison said, the performance is still good though I add bones which don't affect any skin vertex. It's all right! Thanks everyone!

avatar image
1

Answer by Waz · Jul 04, 2011 at 11:55 AM

The skewing you see is exactly what you should expect. While you may seem to be scaling bones in Maya, perhaps you're just scaling the bone envelope. Regardless, once you have the model in Unity, any non-uniform scale of transforms will cause a skew in child transformed bones. You can see this effect in normal unskinned meshes too.

The reason is that scaling does not happen by a multiplying of X, Y, and Z independently, any more than position is merely the sum of parent transforms by independent axes. You would not want the arms to move 5 units along their Y local axis every time the player jumped the spine by 5 units vertically. So similarly, scaling the body by 5 times in the Y will not make the arms 5 times longer in their Y.

Only uniform (equal x,y,z) scaling will appear unskewed on child transforms (bones or otherwise). There is also no simple "unscaling" you can do in child bones.

As a corollary, you can safely scale the final bones non-uniformly (since they have no children).

Comment
Add comment · Show 4 · 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 Ananta · Jul 05, 2011 at 07:46 AM 0
Share

Thanks Warwick.

I can't adopt the way in your another comment due to bone number limitation of my project.

But I'm going to try another method, hinted by your answer "can safely scale the final bones non-uniformly".

It doesn't still work... but thanks anyway!

avatar image Waz · Jul 05, 2011 at 07:56 AM 0
Share

To clarify by example, you can have a "tummy" bone attached to you "spine" bone, and scale the tummy to make the character fat, without affecting other bones (since none are connected to the tummy bone).

avatar image Waz · Jul 05, 2011 at 07:58 AM 0
Share

Also note that performance is more affected by the number of bones which actually affect any skin vertex than by the total number of bones.

avatar image Ananta · Jul 08, 2011 at 02:11 AM 0
Share

All right, now I can scale spine by scaling tummy bone and without affecting other bones. And naturally fatted tummy mesh eat away at arms meshes... Yes "independently scale" is here, I am foolish.

avatar image
1

Answer by Waz · Jul 04, 2011 at 10:42 PM

One way to do "scaling" is just to have two bones above move them further apart, thus stretching the skin between them. Combined with uniform scaling, this may be sufficient for what you're trying to do.

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

Answer by macs_yums · Jul 04, 2011 at 07:32 AM

And I am worried just about the same process.

Version 3.3 of my environment Unity3D, is the iPhone Pro Android Pro.

The local scale of the bone, what's a setting not solve, such as to affect the local scale of the bones of the child?

As far as experimenting with Maya, there is no problem changing the scale of the bones are free to In the same way I do it Unity3D.

Scaling of bone in the other games I use the Avatar seems like doing.

How well do you resolve it not?

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 Waz · Jul 04, 2011 at 11:56 AM 0
Share

This is a comment to the Question, not an Answer. If you could move it, that would help the indexing. TIA

avatar image
0

Answer by Paulius-Liekis · Jul 11, 2011 at 12:52 PM

Yeah, don't do non-uniform scaling - it will look weird when you will start animating the character (for example hands will be longer when they are in front compared to when they are at the sides).

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

uGUI keep position and size of GUI elements when anchors change 3 Answers

Saving default transform of an object c# 1 Answer

Why does localscale of transform set randomly to (0,1,1) and (0,0,0) on level load? 1 Answer

How is transform.position affected by scaling? 1 Answer

How do you Scale Game Objects with the Screen? 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