I am trying to fix this issue around 5 hours reading different posts, watching youtube videos but
still i cant find reason why is not working (my IDLE and WALK animation work perfect)
Character is jumping and walking but when jumps no animation is played…
PLAYER SCRIPT
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
[SerializeField]
public float speed;
private float moveInput;
private Rigidbody2D rb;
[SerializeField]
public float jumpForce;
private bool facingRight = true;
private bool _resetJump = false;
private bool _grounded = false;
public Transform groundCheck;
public float checkRadius;
public LayerMask whatIsGround;
private int extraJumps;
public int extraJumpsValue;
private PlayerAnimation _playerAnim;
private SpriteRenderer _playerSprite;
void Start()
{
extraJumps = extraJumpsValue;
rb = GetComponent();
_playerAnim = GetComponent();
_playerSprite = GetComponentInChildren();
}
void FixedUpdate()
{
_grounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);
moveInput = Input.GetAxis(“Horizontal”);
rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);
if (facingRight == false && moveInput > 0)
{
Flip();
}
else if (facingRight == true && moveInput < 0)
{
Flip();
}
_playerAnim.Move(moveInput);
}
void Update()
{
if (_grounded == true)
{
extraJumps = extraJumpsValue;
}
if (Input.GetKeyDown(KeyCode.Space) && extraJumps > 0)
{
rb.velocity = Vector2.up * jumpForce;
extraJumps–;
}
else if (Input.GetKeyDown(KeyCode.Space) && extraJumps == 0 && _grounded == true)
{
rb.velocity = Vector2.up * jumpForce;
rb.velocity = new Vector2(rb.velocity.x, jumpForce);
_playerAnim.Jump(true);
}
}
void Flip()
{
facingRight = !facingRight;
Vector3 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}
bool IsGrounded()
{
RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, Vector2.down, 0.7f, 1 << 8);
Debug.DrawRay(transform.position, Vector2.down, Color.green);
_grounded = IsGrounded();
if (hitInfo.collider != null)
{
if (_resetJump == false)
{
_playerAnim.Jump(false);
return true;
}
}
return false;
}
}
PLAYER ANIMATION SCRIPT
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAnimation : MonoBehaviour
{
public Animator _anim;
void Start()
{
_anim = GetComponentInChildren();
}
public void Move(float move)
{
_anim.SetFloat(“Move”, Mathf.Abs(move));
}
public void Jump(bool jumping)
{
_anim.SetBool(“Jumping”, jumping);
}
please format your thread to expect any help afterwards
code snippets goes into [code ] tags, use the little icon from the post editing badge
1 Like
Click Edit your post. Highlight all of your code you provided. Use CTRL+X to “cut” the code out and copy. Next, Click the button circled in red in the image above. Use CTRL+V to paste your code inside the code box.
You’ll get an effect like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
[SerializeField]
public float speed;
private float moveInput;
private Rigidbody2D rb;
[SerializeField]
public float jumpForce;
private bool facingRight = true;
private bool _resetJump = false;
private bool _grounded = false;
public Transform groundCheck;
public float checkRadius;
public LayerMask whatIsGround;
private int extraJumps;
public int extraJumpsValue;
private PlayerAnimation _playerAnim;
private SpriteRenderer _playerSprite;
void Start()
{
extraJumps = extraJumpsValue;
rb = GetComponent<Rigidbody2D>();
_playerAnim = GetComponent<PlayerAnimation>();
_playerSprite = GetComponentInChildren<SpriteRenderer>();
}
void FixedUpdate()
{
_grounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);
moveInput = Input.GetAxis("Horizontal");
rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);
if (facingRight == false && moveInput > 0)
{
Flip();
}
else if (facingRight == true && moveInput < 0)
{
Flip();
}
_playerAnim.Move(moveInput);
}
void Update()
{
if (_grounded == true)
{
extraJumps = extraJumpsValue;
}
if (Input.GetKeyDown(KeyCode.Space) && extraJumps > 0)
{
rb.velocity = Vector2.up * jumpForce;
extraJumps--;
}
else if (Input.GetKeyDown(KeyCode.Space) && extraJumps == 0 && _grounded == true)
{
rb.velocity = Vector2.up * jumpForce;
rb.velocity = new Vector2(rb.velocity.x, jumpForce);
_playerAnim.Jump(true);
}
}
void Flip()
{
facingRight = !facingRight;
Vector3 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}
bool IsGrounded()
{
RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, Vector2.down, 0.7f, 1 << 8);
Debug.DrawRay(transform.position, Vector2.down, Color.green);
_grounded = IsGrounded();
if (hitInfo.collider != null)
{
if (_resetJump == false)
{
_playerAnim.Jump(false);
return true;
}
}
return false;
}
}
PLAYER ANIMATION SCRIPT
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAnimation : MonoBehaviour
{
public Animator _anim;
void Start()
{
_anim = GetComponentInChildren<Animator>();
}
public void Move(float move)
{
_anim.SetFloat("Move", Mathf.Abs(move));
}
public void Jump(bool jumping)
{
_anim.SetBool("Jumping", jumping);
}
This makes it easier to read your code for everyone and increases your odds of getting help.
Welcome to the forum 
Edit:
Your problem might be here:
private int extraJumps;
public int extraJumpsValue;
void Start()
{
extraJumps = extraJumpsValue;
Have you put a value to extraJumpsValue inside of the inspector? If you haven’t then your code would read it as 0 and wouldn’t work. That would be my assumption.