- Home /
 
               Question by 
               JohnRossitter · Apr 08, 2014 at 06:03 PM · 
                raycastvector3offsetworldspace  
              
 
              How to get an offset of a RaycastHit?
Hi Unity,
I'm working with RayCasting in an Editor Window script.
I'm translating where a user clicks on the Scene View to a WorldPoint like so:
         Ray worldRay = HandleUtility.GUIPointToWorldRay(e.mousePosition);
         Debug.DrawRay(worldRay.origin, worldRay.direction * 20, Color.yellow);
         RaycastHit hitInfo;
         if (Physics.Raycast(worldRay, out hitInfo, 20))
         {
             Debug.Log(hitInfo.point);
         }
Doing so will give me the world coordinate of where my ray was intersected, which is great. However, I need to know how to calculate an offset, and get a point in the ray line 1 world unit prior to the intersection. I tried searching the Forums on this one, but just do not know the right words to describe what I'm looking for.
Anyone know how?
Thanks
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                