- Home /
Transform position in between local and absolute?
Hi,
Is there a simple way to get transform information somewhere in between local and absolute? Absolute - position and rotation w.r.t world coords Relative - position and rotation w.r.t parent coords
Desired - For a situation where you have World -> gameObject -> child -> grandChild position and rotation of grandChild w.r.t gameObject coords
Answer by Berenger · Feb 21, 2012 at 02:06 AM
Try doing it by script, not parenting. something simple that copy pos and rot, but letting you choose the transforms you're copying from. In your case, gameObjects. I suppose there is a reason your making grandChild child of child (well, that's akward) but the script will override that relation.
Answer by forager · Feb 21, 2012 at 12:11 PM
I came up with a simple solution and I think it might be the same as what you meant, Berenger. Given the same heirarchy as in the original (world -> gameObject -> child -> grandChild), and a script attached to gameObject:
Transform child;
Transform grandChild;
Vector3 gcLocalPosition;
void setGCLocalPosition() {
grandChild.parent = transform;
gcLocalPosition = grandChild.localPosition;
grandChild.parent = child;
}