Hey, so im having this problem. Im getting an error. Any ideas whats wrong here?
-Thanks!
Ray2D ray = new Ray2D(transform.position, rayPosInc);
Debug.DrawRay(transform.position, rayPosInc, Color.blue);
if (Physics2D.Raycast(ray, out hit)) //This is where i get the error;
{
//code...
}
The best overloaded method match for `UnityEngine.Physics2D.Raycast(UnityEngine.Vector2, UnityEngine.Vector2, float)’ has some invalid arguments. Yes it is a RaycastHit2D.
Ray casting in 2D is different from in 3D. Check out the docs above. The method returns the RaycastHit2D directly, rather then a bool. No need to use the out keyword.