- Home /
 
 
               Question by 
               siddharth3322 · Aug 08, 2019 at 03:16 PM · 
                physicsraycastcolliderdetectionphysics.raycast  
              
 
              Slant Physics Raycast Implementation
For my 3d car game, I was doing Physics raycast to detect obstacles and based on detect take turn left or right side. Currently, I was doing straight raycast and I can't able to detect left and right side existed obstacles. 
 So I decided to do little bit slant raycast to detect something from the left and right side. The following image explains a better way my question:
 
 This code is running at present:
         Ray rayRight = new Ray(thisTransform.position + Vector3.up * 0.2f + thisTransform.right * detectAngle * 0.5f + transform.right * detectAngle * 0.0f * Mathf.Sin(Time.time * 50), transform.TransformDirection(Vector3.forward) * detectDistance);
         Ray rayLeft = new Ray(thisTransform.position + Vector3.up * 0.2f + thisTransform.right * -detectAngle * 0.5f - transform.right * detectAngle * 0.0f * Mathf.Sin(Time.time * 50), transform.TransformDirection(Vector3.forward) * detectDistance);
 
         Debug.DrawRay(rayRight.origin, rayRight.direction * detectDistance, Color.red);
         Debug.DrawRay(rayLeft.origin, rayLeft.direction * detectDistance, Color.red);
 
               Now please give me a guidance to do slant physics raycast to detect obstacles.
 
                 
                drifter-car-raycast.png 
                (39.3 kB) 
               
 
              
               Comment
              
 
               
              Your answer