NoGo86
November 2, 2012, 2:27am
1
Info… I have a parent Cube with a separate collision box on each side attached to an empty as its children. Each empty is named CubeSideX as x is 1-6.
I am rotating the parent as such (Temporarily)
if (Input.GetKeyDown(KeyCode.Z))
{
transform.Rotate(90, 0, 0);
}
I Store the Y position of each CubeSide with this
CubeSide1PosY = CubeSide1.transform.position.y;
I then determine which side has the highest Y value and put a “TOP” Tag on it.
Question… Why does My CubeSide Position not change as I rotate my parent? I thought transform.position gets the world position?
If
if (Input.GetKeyDown(KeyCode.Z))
{
transform.Rotate(90, 0, 0);
}
is what you are using, I don’t see where specify it rotating to face the object.
Are you trying to have the Target look at the Object? ( Does Transform LookAT () work for you ? )
function Look ( )
{
gameObject.transform.LookAt ( Target.transform ) ; // Param Type 'Transform'
}
If you’re trying to get the child to rotate along with the parent, you really shouldn’t change your rotation values… It does this automatically.
NoGo86
November 12, 2012, 4:53am
3
Instead of the accessing the child position via gameobject.transform.position.x ect. I set the (x, y & z) axis to var’s on each child and accessed them from the parent with
var xPosSide1 : float = transform.Find("Side1").GetComponent(ScriptSide).xPos;
its a bit more code then I would like but it does what I need.