In my player controller script, I have various checks that determine the state of a player (E.g. isGrounded, isTouchingWall, etc.)
For the ones like isGrounded and isTouchingCeiling, there is no need to invert them since the player can only flip on the Y axis, however, I’m having trouble flipping the isTouchingWall raycast.
The empty gameObject that the raycast takes as the start point flips as usual since it’s a child of the player, but the direction of the raycast (transform.right) does not, so even if the player is looking left that raycast goes into the player and to the right.
A solution I thought worked was doing the following:
if(isFacingRight)
{
isTouchingWall = Physics2D.Raycast(wallCheck.position, transform.right, wallCheckDistance, whatIsGround);
} else {
isTouchingWall = Physics2D.Raycast(wallCheck.position, -transform.right, wallCheckDistance, whatIsGround);
}
However, that seemed to unable the entire raycast and now only returns a false value even if I’m next to a wall. This code is inside a method inside the FixedUpdate(); method, if that matters.
Any answers are greatly appreciated, and thanks in advance ![]()