How to Avoid Skew?

I’m getting skew of a child object as mentioned on the Unity Script Reference Transform.lossyScale page http://unity3d.com/Documentation/ScriptReference/Transform-lossyScale.html. I have an oblong sphere rotating and a child 3D Text object that I would like to hang above the sphere without rotating with the sphere. I’m using a script something like this:

function Update() {
	if (!transform.parent)
		return;
	
	// update position and rotation to look at camera
	transform.position = transform.parent.position;
	transform.position.z = transform.position.z + 1;
	
	transform.eulerAngles = Vector3(90, 0, 0);
}

I would like to keep the text as child for organization, prefab, scripting, and other reasons, but I can’t figure out how to counteract the skew. Options I can think of are: a) figure out how to properly counter-act skew/rotation/etc. in realtime; b) have it be a child without being “transform child”; or c) when the scene launches, have the text drop out of being a child but still retain connections to work properly.

Let me knew what would work and would be the best, easiest way to go. Thanks.

I have some ideas:

You need to have clear how transformation are applied, transformation are applied to children of the transformed object, so, doing a good hierarchy will easy the concept of follow, rotation, position, etc. and your scripts will be easy to implement.

Here is a package with some routines, i think i covered almost any combination, including what you are asking for… if not, let me know.

Omar Rojo

30359–1119–$samples_267.unitypackage (11.7 KB)

Skew happens if you have a non-uniform scale on the parent. (A scale that is different on each axis)
And the child has a rotation that does not align with the primary axes. (Eg. 30 degree rotation around y axis.)