I have a slider attached to a canvas that is parented to another Gameobject. I’m aware of the following script which can be attached to the canvas which allows the slider to always face the camera, however once the canvas is parented, the slider starts to distort and face the wrong direction.
transform.LookAt(transform.position + Camera.main.transform.rotation * Vector3.forward, Camera.main.transform.rotation * Vector3.up);
*Note I’m using a variation of this script on the parent object that has a reference to the child canvas Gameobject.
Similarly to this I’d like the UI element to also maintain the same scale regardless of how close or far away the camera is.
I don't understand your LookAt usage. To look at the camera, you simply need: transform.LookAt(Camera.main.transform.position, Vector3.up). transform.LookAt(transform.position,...) causes the object to try to face itself, which causes unpredictable results.
– ArachnidAnimalI should have clarified this is a FPS game so the camera is attached to a player object where the camera is rotated around with the mouse, so the LookAt needs to account for camera rotation not just position. Like I mentioned that script works as intended when the UI canvas isn't parented, however parenting to another game object seems to mess up the calculation. Regardless I realised this wasn't the best solution for what I was trying to do and instead used WorldToScreen point to find the parented objects position then set the UI to screenspace which did the trick.
– mutedhue