Help with Layer mask to not detect player hitbox
Hi, I'm kind of new to unity and i'm making a 2d Platformer but cant quite get a ray cast to work. The raycast constantly returns true which i believe is because the ray is hitting the players own hitbox. Ive been attempting to use Layer mask to filter out the players hit box but it isnt working. Heres some of my code:
Vector3 down = transform.TransformDirection(Vector3.down);
if (Physics.Raycast(transform.position, down, groundDistance, 1 << 8)) ;
{
print("there is ground below the player");
}
I have the player set as layer 8 and the ground as layer 9. no matter where my character is in the stage it still proceeds to print "there is ground below the player". The '1 << 8' should filter out the player but for some reason it doesn't. Thanks for the help in advance.
Your answer
Follow this Question
Related Questions
2d platformer knockback without addforce 1 Answer
Raycast Reflection 2D 1 Answer
Allow raycast to skip an object with rigidbody 0 Answers
Gradually rotate to slope angle 3 Answers
transform.SetParent() not setting the object I want as parent. 2 Answers