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 Jason_DB · Jul 07, 2010 at 03:04 PM · rigidbodyparent

Making object a child causes distortion/skewing

I'm trying to make an arrow projectile, so when the arrow hits a collider, the collider becomes its parent (so that the arrow will move with the collider, and it will look like it's embedded in it). The only problem is that sometimes when the arrow is made a child it gets distorted and stretches/skews in very strange ways.

Is there anything that I can do about this? I know that sometimes objects behave strangely when made children, but not how to fix/avoid it.

P.S. the arrow is a rigidbody but I make it kinematic on collision, and the target is currently a cube

Thank you in advance to anyone who answers!

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

4 Replies

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

Answer by Miriam · Jul 07, 2010 at 05:56 PM

Hi,

I'm having similar problems. (my post: http://answers.unity3d.com/questions/14594/geometry-distortion-on-child-objects)

The standard cause for this problem (which didn't help me but may help you) seems to be a combination of:

  • non uniform scaling on your parent object.
  • AND arbitrary rotation on your child object.

Hope that helps


Edit: Having uniform scaling on my child objects (not just parent ones) seems to be helping a bit with the skewing problem.

Also, you could try set up a script like this on the arrow object:

var followThisObject : GameObject;

function onHitObject (objectHit : GameObject){ followThisObject = objectHit; }

function Update(){ if (followThisObject != null){ transform.position = followThisObject.transform.position; transform.rotation = followThisObject.transform.rotation; } }

Then when the arrow hits an object send an "onHitObject" message to the arrow.

You might also need to store variables with the relative position & rotation of the arrow to the hit object and add those each update as well.

Good luck!

Comment
Add comment · Show 3 · 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 Jason_DB · Jul 07, 2010 at 09:04 PM 0
Share

Thanks. Unfortunately i'm firing arrows in a full scene so both of those are givens (I was hoping there was something else which could be causing it).

avatar image Miriam · Jul 07, 2010 at 09:42 PM 0
Share

If you can't figure out a proper solution you could always fake it - ie ins$$anonymous$$d of parenting the arrow put a script on the arrow that makes it follow the cube.

avatar image Jason_DB · Jul 10, 2010 at 11:26 PM 0
Share

Well the issue is that the arrow can stick into anything, including hinged objects and such, in my scene.

avatar image
0

Answer by Andy.... · May 30, 2014 at 03:04 PM

There is another easier way to solve it ( at least, worked for me)

Example:

 Vector3 originalScale = transform.localScale;
 
 // Do parenting stuff...
 
 transform.localScale = originalScale;
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 playa1337 · Jun 15, 2014 at 06:39 PM 0
Share

thanks. this solution did work for me!

 ePrefabs.Add(Instantiate(Resources.Load(tempString, typeof(GameObject))) as GameObject);
 var originalScale : Vector3 = ePrefabs[i].transform.localScale;
 ePrefabs[i].transform.parent = Platform.transform;
 ePrefabs[i].transform.localScale = originalScale;
 ePrefabs[i].transform.localPosition = pos;
avatar image
0

Answer by Noise crime · Jul 10, 2010 at 10:52 AM

If its a case of non-uniform scaling you could use an empty game object as the parent to the collider. So instead of moving the collider, you now move the parent. You still check collisions through the collider, but when attaching the arrow, you attach it to the empty game object instead.

This means your collider can have non-uniform scaling, but your arrow wont inherit it as its no longer parented directly to it.

Comment
Add comment · Show 3 · 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 Jason_DB · Jul 10, 2010 at 11:26 PM 0
Share

Well the collider can be anything in the scene, so I would prefer not to put empty gameobjects on everything with a collider.

avatar image Jason_DB · Jul 10, 2010 at 11:26 PM 0
Share

Although I could be misunderstanding.

avatar image Noise crime · Jul 11, 2010 at 12:44 AM 0
Share

No thats pretty much the idea, but if its going to stick to everything then I can understand not wanting to parent empty game objects.

avatar image
0

Answer by George-Dolbier · Apr 21, 2018 at 02:37 PM

Just confirmed this is still a bug in Unity 2017.3.1f1 Not saving and restoring localScale of a child object of an object with skewed scale, causes really bizarre behaviour. It looks like the child object's scale is tweaked by the inverse of the parent's scale squeue. My parent object scale was skewed in only one axis and all my children where stretched along the same axis. but saving the local scale and restoring it does not exactly fix the problem. Local Scale shows up in the editor as the original scale of the object, but the objects are now all the same absolute dimension (meaning parent and child are the same width, even though the child prefabs where much wider).

Comment
Add comment · Show 2 · 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 Bunny83 · Apr 21, 2018 at 03:12 PM 0
Share

This is not a bug but the simple result of a chained linear transformation. When you have a non uniform scale on the parent and a rotated child there is absolutely no way to preserve the childs shape as the scaling will not be aligned with the local axes. Therefore you can not set any reasonable scale on the child which could undo the transformations. That's also the reason why there is no "world space" scale but only a localScale and a lossyScale. The lossyScale tries to approximate the world space scale, but with a non uniform scaling and rotation it's impossible to restore the original scale of the object. It would require you to undo all transformations in reverse which is not possible with a single matrix. You may want to have a look at this video which explains this problem a little bit in detail.


If you have a parent-child relationship you just don't want to have a non uniform scaling on the parent. Just create an empty gameobject which acts as parent and give it a scale of (1,1,1). Then just add your original "parent" as well as the child both as child to the empty gameobject.


Non uniform scaling also has an impact on performance. Objects with non uniform scaling can't be batched. Also Unity can actually detect a uniform scaling and simplify the transformation.

avatar image Bunny83 Bunny83 · Apr 21, 2018 at 03:25 PM 0
Share

ps: Non-uniform scaling also may give you trouble with surface normals, especially when the normal is not aligned with the local axes.

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

Connecting Multiple Rigidbodies with Collision 0 Answers

Child Gameobjects are not fixed to the parent when using physics 0 Answers

Add sub object to Rigidbody 1 Answer

Empty Object as Parent without Rigidbody? 0 Answers

Touch the same GUITexture button to Pick Up and Drop a Rigidbody Game Object 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