Or, have the ‘child’ not really be a child of the parent, but have a script on it that is constantly setting its position = the parents, + some offset vector (in a lateUpdate(), for total syncronization).
If you only want to track position, it’s easier to just track position with your own script rather than trying to undo rotation (and possibly scale) from a parent.
I sort of did this with a shadow projector, but it was a simpler situation - I wanted it only to rotate around the Global Y with it’s parent (didn’t want it projecting the shadow at crazy angles as the aircraft banked).
So I basically set the projector’s transform.rotation each update for x z to zero and left Y alone…have to look up the code later when I get home.
Good suggestions guys. The problem gets a bit more complicated because consider this application:
A helicopter is composed of a body and the top rotor blades. The blades are set as a child of the helicopter game object and given a fixed rotation. But, when the helicopter parent object itself rotates, the rotor blades’ speed changes in a weird way.
Would you make the rotate blades an entirely separate object and update it’s x,y,z via Update()? That seems unwieldy, no?
Is there a difference in performance if I update the position manually – through Update() – versus parenting?
Or, have the ‘child’ not really be a child of the parent, but have a script on it that is constantly setting its position = the parents, + some offset vector (in a lateUpdate(), for total syncronization).
Quaternion spawnRot = Quaternion.Euler(90f, 0f, 0f); //setting the rotation of the object to what it originally is
void LateUpdate()
{
transform.rotation = spawnRot; //transforming the rotation each update to that rotation
}