{
public Rigidbody2D rb;
public float speed;
public float moveInput;
public float jumpForce;
private bool facingRight = true;
private bool isGrounded;
public Transform feetPos;
public float checkRadius;
public LayerMask whatIsGround;
private Animator anim;
void Start()
{
rb = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
}
// Update is called once per frame
void FixedUpdate()
{
moveInput = Input.GetAxis("Horizontal");
rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);
if (!facingRight && moveInput > 0)
{
flip();
}
else if (facingRight && moveInput < 0)
{
flip();
}
if (moveInput == 0)
{
anim.SetBool("isRunning", false);
}
else
{
anim.SetBool("isRunning", true);
}
}
private void Update()
{
isGrounded = Physics2D.OverlapCircle(feetPos.position, checkRadius, whatIsGround);
if (isGrounded == true && Input.GetKeyDown(KeyCode.Space))
{
rb.velocity = Vector2.up * jumpForce;
anim.SetTrigger("takeOf");
}
if (isGrounded == true)
{
anim.SetBool("isJumping", false);
}
else
{
anim.SetBool("isJumping", true);
}
}
void flip()
{
facingRight = !facingRight;
Vector3 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}
}
Как сюда прикрутить звуки шагов? вообще не понимаю куда именно можно вставить