How to make a billboard that has a physics object as parent.

I’m using the script from here to make a camera facing billboard that only rotates on the Y axis to face the camera.

The problem is that when my object has a physics object as a parent then the script in question locks all other rotations of the billboard. This makes it so that the billboard follows the position of the parent, but not the rotation.

What changes would I have to make to the script in order to make the billboard rotate with the parent and still face the camera on the local Y axis?

I’ve always made billboards that face the camera along Z, is using Y necessary? When issues like this come up I’ve found it’s sometimes easier to separate the constrained child from the parent altogether. This gives you total control over the former child’s transform at the expense of refactoring any code that relies on object B being a child of A. There are solutions to this that maintain parent/child relationships, but afaik they employ heavy order-of-operations control to avoid oscillating errors, gimbal lock, and other fun things. Basically you do your math to point the child “at” the camera after any operations which affect the parent during that frame. This could be as easy as A.B.LookAt( cam ); but might be more complicated depending on what all you’re doing.

I misspoke. I meant to rotate around it’s Y axis while facing the Z direction to camera. The problem isn’t really with the child parent relationship but with the script on the Wiki. (The link disappeared because I copy pasted this post). The script locks down all rotations except Y by assigning the new vector as zero for all directions exempt Y. I’m curious how I would modify the script to make the rest of the directions freely modifiable.