I'm displaying a ring wherever the camera 'looks'. When the camera faces the ground (green) the ring image always looks correct, see image:

enter image description here

However, my scene is within a sphere (purple)... and when the ring reaches the sphere it does not display correctly. See image:

enter image description here

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);
  • 1
    \$\begingroup\$ Have you tried simply rotating the ring to be perpendicular to the view vector? \$\endgroup\$
    – DMGregory
    Commented May 30, 2018 at 1:03
  • \$\begingroup\$ Thanks for the quick reply. I'm still very new (especially the math) so bare with me. Right now I am doing this: imageTransform.rotation = Quaternion.FromToRotation (Vector3.forward, rayhit.normal); Note that my rayhit is coming in the reverse direction. Long story short you can't raycast to a collider from within the collider itself, so I'm picking a point outside the collider (sphere) and casting inwards towards my camera. \$\endgroup\$
    – BrianLegg
    Commented May 30, 2018 at 1:09
  • \$\begingroup\$ If you want to share code or details about your current method, use the edit link to add it into your question itself. You get better formatting that way. \$\endgroup\$
    – DMGregory
    Commented May 30, 2018 at 1:10

1 Answer 1


So, it ended up being a combination of rotations... one for the ground and one for the sphere. It's a little hacky, but here's my solution. Hopefully it helps someone else out:

Target.transform.position = hit.point;
if (hit.collider.gameObject.tag == "GroundTeleportationZone")
     Target.transform.rotation = Quaternion.FromToRotation(Vector3.down, hit.normal);
     Target.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.point);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .