hello, i am trying to make a wall jump, so i put a ray cast on the side of the player, and put a one tile on the ground and then i put the player against it and it worked. but when i put a whole wall of tiles it said canWal
using UnityEngine;
public class WallJump : MonoBehaviour
{
[SerializeField] private LayerMask groundLayerMask;
public BoxCollider2D boxCollider2D;
public bool CheckIfOnWallToRight()
{
RaycastHit2D onWall = Physics2D.Raycast(new Vector3(boxCollider2D.bounds.max.x, boxCollider2D.bounds.max.y, 0), Vector2.down, .55f, groundLayerMask);
// sets ray color depending on state
Color rayColor;
if (onWall != true)
{
rayColor = Color.red;
}
else
{
rayColor = Color.green;
}
// shows ray
Debug.DrawLine(new Vector3(boxCollider2D.bounds.max.x, boxCollider2D.bounds.max.y - .02f, 0), new Vector3(boxCollider2D.bounds.max.x, boxCollider2D.bounds.min.y + .02f, 0), rayColor);
return onWall;
}
// check to the left
public bool CheckIfOnWallToLeft()
{
RaycastHit2D onWall = Physics2D.Raycast(new Vector3(boxCollider2D.bounds.min.x - .1f, boxCollider2D.bounds.max.y, 0), Vector2.down, .55f, groundLayerMask);
// sets ray color depending on state
Color rayColor;
if (onWall != true)
{
rayColor = Color.red;
}
else
{
rayColor = Color.green;
}
// shows ray
Debug.DrawLine(new Vector3(boxCollider2D.bounds.min.x, boxCollider2D.bounds.max.y - .02f, 0), new Vector3(boxCollider2D.bounds.min.x, boxCollider2D.bounds.min.y + .02f, 0), rayColor);
return onWall;
}
}