I'm displaying a ring wherever the camera 'looks'. When the camera faces the ground (green) the ring image always looks correct, see image:
However, my scene is within a sphere (purple)... and when the ring reaches the sphere it does not display correctly. See image:
This second image, the ring should be facing the camera since it's on a surface that is in front of the camera (not on the ground like the image appears).
Sorry if my images are poor representations. I basically have a flat plane which is within a sphere. The sphere has flipped normals to be able to display from within the sphere. I need the ring to "attach" or bend to the shaped of the object it is being drawn against. Any help is greatly appreciated.
EDIT: (more details). You can't raycast to a collider from within the same collider, so I'm using a raycast in the opposite direction. Code:
Ray ray = new Ray(m_Camera.position, m_Camera.forward); // get ray
Vector3 forwardVector = ray.GetPoint(100); // get a point 100 away
ray = new Ray(forwardVector, m_Camera.forward); // create new ray from this point
ray.direction = -ray.direction; // reverse ray direction
if (Physics.Raycast(ray, out hit, m_RayLength, ~m_ExclusionLayers)) {
imageTransform.rotation = Quaternion.FromToRotation (Vector3.forward, hit.normal);
}