Столкнулся с проблемой, когда персонаж подходит к стене, в инспекторе на bool не появляется галочка
(не проверяется).
На персонаже есть 2 пустышки с колайдером
(is Trigger включено) вот скрипт
public class Buttons : MonoBehaviour
{
public float speed;
public float jumpForce;
public Joystick joystick;
public float dirX, dirY;
private Rigidbody2D rb;
public bool facingRight = true;
private bool isGrounded;
public Transform feetPos;
public float checkRadius;
public LayerMask whatIsGround;
private Animator anim;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
WallCheckRadiusUp = WallCheckUp.GetComponent<CircleCollider2D>().radius;
WallCheckRadiusDown = WallCheckDown.GetComponent<CircleCollider2D>().radius;
}
private void FixedUpdate()
{
rb.velocity = new Vector2(dirX, dirY);
CheckingWall();
}
//Ты Негр?
private void Update()
{
isGrounded = Physics2D.OverlapCircle(feetPos.position, checkRadius, whatIsGround);
dirX = joystick.Horizontal * speed;
if (dirX == 0)
anim.SetBool("Walk", false);
else if (dirX > 0)
anim.SetBool("Walk", true);
else if (dirX < 0)
anim.SetBool("Walk", true);
if (dirX > 0 && !facingRight)
Flip();
else if (dirX < 0 && facingRight)
Flip();
CheckingWall();
}
private void Jump()
{
rb.velocity = Vector2.up * jumpForce;
if (isGrounded == false)
{
anim.SetBool("Jump", true);
}
if (isGrounded == true)
{
anim.SetBool("Jump", false);
}
}
private void Flip()
{
facingRight = !facingRight;
transform.Rotate(0f, 180f, 0f);
}
public bool onWall;
public LayerMask Wall;
public Transform WallCheckUp;
public Transform WallCheckDown;
private float WallCheckRadiusUp;
private float WallCheckRadiusDown;
void CheckingWall()
{
onWall = (Physics2D.OverlapCircle(WallCheckUp.position, WallCheckRadiusUp, Wall) && Physics2D.OverlapCircle(WallCheckDown.position, WallCheckRadiusDown, Wall));
anim.SetBool("onWall", onWall);
}
}