How to make a "raycast" vertically in front of the player ?
Hello first excuse me spelling I am french .. I created a vertical "raycast" of 2 units and 3 units in front of the player but my "raycast" did not hit anything!
CODE : (when I press "space")
void jump()
{
LayerMask layer = 1 << 2;
layer = ~layer;
RaycastHit hit;
if (Physics.Raycast(gameObject.transform.position + (transform.forward * 3f), transform.up, out hit, 2f,layer))
{
print(hit.transform.gameObject.name);
}
else
{
print("vide");
}
}
Comment