[Solved]Geometry Distorts on Parenting?

Hi,

Happy Belated Solstice! :slight_smile:

I have a projectile that I want to attach to another object when they collide. I’m attempting to do this by parenting the projectile to the target object. I can see in the Hierarchy view that it does indeed get parented, but the geometry of the projectile, which is a sphere, gets squished (as shown below - the cylinder is the target/parent object). I can see in the inspector that the Scale of the projectile has been changed so that is no longer a sphere. Here’s my code:

if (objectHit.tag == "Socket") {
  BulbSocketController socketController = objectHit.GetComponent<BulbSocketController>();
  if (!socketController.HasBulb) {
    this.rigidbody.velocity = Vector3.zero;
    this.rigidbody.isKinematic = true;
    this.transform.parent = objectHit.transform;
    socketController.HasBulb = true;
  }
}

If I comment out this line:

//this.transform.parent = objectHit.transform;

the sphere is not squished. Any idea what I’m doing wrong?

Thanks for your help!

Mal

241450--8657--$squishedsphere_964.jpg

Most likely, you have non-uniform scaling in the parent object. Non-uniform scaling means you have different values for the x,y and/or z scaling of that object. Non-uniform scaling in combination with rotation on the child object will result in skewing. This is how the underlying math works and the best solution to it is to not have non-uniform scaling at all. This can be achieved by having your models already in the correct aspect ratio for your game.

Thanks for the info! This scaling issue is a problem I was completely unaware of until this situation arose.

Also, there is more information and possible workarounds to be found here:

http://answers.unity3d.com/questions/1858/geometry-distorts-on-parent-assignment

Cheers,
Mal