- Home /
How to convert Raycast3D to Raycast2D
Hi, I am absolute beginner to Unity. I was going through Live training Jan 26th, 2015 - "Creating A Casual Jewel Mining Game ". Its a 3D game. I applied this into my 2D game but its not working. I found that its because of a script in which Raycast is used for 3D whereas I should convert it to 2D. Could some please help me to convert below 3 lines according to 2D?
     RaycastHit hit;
     Vector3 down = transform.TransformDirection(Vector3.down);
     if(Physics.Raycast(transform.position, down, out hit, 100))
     {
         claw.SetActive(true);
         clawScript.ClawTarget(hit.point);
     }
               Comment
              
 
               
              Answer by jonasmortensen · May 17, 2017 at 09:09 AM
Hello,
Unity has two different physics engines. One for 3d (Physics) and one for 2d (Physics2D). Both have a Raycast function so my guess is that you need to use Physics2D.Raycast instead.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                