Why only the first frame plays in my jump animation
As a starter on Unity I decided to download an asset and do the basics before I start creating my own using photoshop. So everything was going well (Im making a 2d platformer btw) until I got into jump animation. When I jump only the first frame of the animation plays. this is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Controller : MonoBehaviour {
public float Speed;
public float jumpForce;
private float playerInput;
private Rigidbody2D rb;
private bool facingRight = true;
public Animator anim;
public Transform groundCheck;
public float radiusCheck;
public LayerMask whatIsGround;
bool isGrounded;
private int extraJumps;
public int jumpValue;
void Start()
{
extraJumps = jumpValue;
rb = GetComponent<Rigidbody2D>();
}
void FixedUpdate()
{
isGrounded = Physics2D.OverlapCircle(groundCheck.position,radiusCheck,whatIsGround);
anim.SetFloat("speed", Mathf.Abs(playerInput));
if(isGrounded == true && Input.GetKeyDown(KeyCode.UpArrow))
{
anim.SetBool("myManIsJumping", true);
}
else
{
anim.SetBool("myManIsJumping", false);
}
playerInput = Input.GetAxis("Horizontal");
rb.velocity = new Vector2(playerInput * Speed, rb.velocity.y);
if (facingRight == true && playerInput < 0)
{
flip();
}
else if (facingRight == false && playerInput > 0)
{
flip();
}
}
void flip()
{
facingRight = !facingRight;
Vector3 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}
void Update()
{
if(isGrounded == true)
{
extraJumps = jumpValue;
}
if(Input.GetKeyDown(KeyCode.UpArrow | KeyCode.W) && extraJumps > 0)
{
rb.velocity = Vector2.up * jumpForce;
extraJumps--;
}else if (Input.GetKeyDown(KeyCode.UpArrow) && extraJumps == 0 && isGrounded == true)
{
rb.velocity = Vector2.up * jumpForce;
}
}
}
If anyone can give me help I would appreciate it :)
you need to share screenshots/gif of the animator page for us to try and help you
@xxmariofer this is my picture of animator
Also now I cant even see which animation plays at the animator for some reason. I cant screenshot the green bar only filling the 1/20th of the jump animation. Any ideas whats wrong?
@xxmariofer also here is the gif too (Just found out I just didnt have selected my gameobject).
It looks like the var that enables the jump to iddle animation is always tru, whats that variable name?
Your answer
![](https://koobas.hobune.stream/wayback/20220612194140im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Custom Jump Arc 0 Answers
How to make my character fall when running against a collider. 1 Answer
2D jump problem when hits wall 0 Answers
Jumping on enemies help 0 Answers
Collision detector suddenly stops detecting collision when move the player! Bug? 0 Answers