- Home /
Help Can't find the Correct Parameters
So I am trying to use a raycast hit and a layermask apparently this just does not bode well with unity Here is the line:
if(Physics.Raycast(transform.position, transform.forward, Mathf.Infinity, hit, LayerM))
Here is the error:
BCE0023: No appropriate version of 'UnityEngine.Physics.Raycast' for the argument list '(UnityEngine.Vector3, UnityEngine.Vector3, float, UnityEngine.RaycastHit, UnityEngine.LayerMask)' was found.
I understand that it is because I am not using the correct parameters but... what parameters can I use?
Answer by robertbu · Mar 02, 2014 at 06:13 PM
The problem is with your LayerM. Raycast uses an 'int', and you are passing a LayerMask. You can use LayerMask.value:
if(Physics.Raycast(transform.position, transform.forward, Mathf.Infinity, hit, LayerM.value))
I tried that but nothing happened the issue is with the actual parameter list, do you know what Parameters I should use ins$$anonymous$$d?
Oh, you have a second problem. You have the hit and the distance reversed. For the version of Raycast() you are trying to call, here is the signature from the reference:
static function Raycast(origin: Vector3, direction: Vector3, hitInfo: RaycastHit, distance: float = $$anonymous$$athf.Infinity, layer$$anonymous$$ask: int = DefaultRaycastLayers): bool;
lol thanks so much, I thought I had tried that already but, I geuss not! thanks man!