I have a golf ball on the ground, and from a raycast, I have the normal which gives me the slope of the ground by the ball.
I have an object which is rendered on the HUD to show that slope to the player.
I have a parent object rotated -90 degrees around X, so that the indicator's Z-axis points up. This way I can do this:
Quaternion yRot = Quaternion.Euler(0, -CameraController.Instance.CachedTransform.eulerAngles.y, 0); Vector3 displayGroundNormal = yRot * _groundNormal; _lieIndicator3DParentCachedTransform.rotation = Quaternion.LookRotation(displayGroundNormal);
This, as far as I can tell, takes the ground normal, rotates it around the y-axis so that it shows the proper perspective given the camera's facing. Then it tells that parent object to look in that direction, which aligns its z-axis with the rotated ground normal.
This works, except the object I have also rotates around the y-axis depending on the orientation of the camera. I thought that I was throwing that information away in the second step by keeping only a Vector3 aligned with the ground normal rotated for the camera position.
So I want this: