In my Update() function I have:
isGrounded = Physics2D.Linecast (transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"));
if (Input.GetButtonDown ("Jump") && isGrounded) {
jump = true;
}
It works fine, now, I jump using this code in FixedUpdate():
if (jump) {
anim.SetTrigger("Jump");
rb.AddForce(new Vector2 (0f, jumpForce));
jump = false;
}
The problem is, how do I detect that the character landed? I can’t use isGrounded, as it’s true at the point of jump, so the Trigger to change animation back to Idle would launch immediately after jumping.