Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Abbas_1505 · Jul 16, 2020 at 10:47 PM · 2d game2d animation

Jump animation isn't working while running

Hello, im trying to make a 2d game. when i press the space bar to jump, the jump animation is working correctly. but when i run and then press the space bar to jump (while im running), the jump animation isn't working. is just shows the run animation. can anyone please help me fix this problem?,Im trying to make a 2d game. when i press the space bar to jump, my jump animation is working correctly. but when im running and then press space to jump (while im running), the jump animation isn't working. can anyone please help me to fix this problem?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Koishi-_- · Sep 14, 2021 at 08:58 PM

Its probably because you have no transitions on the animator tab.

If this is the case, what should fix it would be making a transition from [Any state] to [Jump] in the animator, and setting said transition's conditions to [IsJumping = true]

Then, making another transition from [Jump] to [Idle], and setting that one's to [IsJumping = false] and [MovementSpeed < 0.001]

Hope it helps :)

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bendago · Sep 15, 2021 at 12:23 PM 0
Share

I did and it doesn't work :(

avatar image rage_co Bendago · Sep 15, 2021 at 01:18 PM 0
Share

have you disabled exit time? sometimes the transitions do take place but wait for the previous animation to end first, and we land in that duration, giving the appearance that the animation didn't work

avatar image Bendago rage_co · Sep 15, 2021 at 04:02 PM 0
Share

yes I did disable exit time and still it doesn't work

Show more comments
avatar image
0

Answer by JMasterBoi · Jul 17, 2020 at 01:11 AM

This also happened to me. This could be happening because you are using if and else if statements. this means that only one will happen at a time. You can fix this by having both of them being if statements. If you want a better or more specific explanation you are going to have to show your code.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Abbas_1505 · Jul 19, 2020 at 12:18 PM 0
Share

I posted the script

avatar image
0

Answer by Abbas_1505 · Jul 17, 2020 at 09:24 AM

That is my PlayerMovement script but im also working with a character controller.

 using Microsoft.Win32;
 using System.Collections;
 using System.Collections.Generic;
 using System.Collections.Specialized;
 using UnityEngine;
 
 public class PlayerMovement : MonoBehaviour {
 
     public CharacterController2D controller;
     public Animator animator;
 
     public float runSpeed = 40f;
 
     bool jump = false;
     bool crouch = false;
 
     float horizontalMovement = 0f;
 
     // Update is called once per frame
     void Update()
     {
                
         horizontalMovement = (Input.GetAxisRaw("Horizontal")) * runSpeed;
 
         animator.SetFloat("Speed", Mathf.Abs(horizontalMovement));
         
 
         if (Input.GetButtonDown("Jump"))
         {
            
           jump = true;
           animator.SetBool("IsJumping", true);
                        
         }
         if (Input.GetButtonDown("Crouch"))
         {
             crouch = true;
 
         }
         if (Input.GetButtonUp("Crouch"))
         {
             crouch = false;
         }
     
     }
 
     public void OnLanding ()
     {
         animator.SetBool("IsJumping", false);
     }
 
     void FixedUpdate ()
     {
         controller.Move(horizontalMovement * Time.fixedDeltaTime, crouch, jump);
         jump = false;
 
        
             
     }
 
 
 
 }
 

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bendago · Sep 14, 2021 at 02:42 PM 0
Share

Brackeys right ? and yeah I got the same problem jump animation isn't work but when I press space botton for second time it start working and I wonder what should I do ?

avatar image arth9130 · Sep 14, 2021 at 02:43 PM 0
Share

Use triggers instead of bools

avatar image Bendago arth9130 · Sep 15, 2021 at 05:42 PM 0
Share

it doesn't work :(

avatar image
0

Answer by skagontale · Sep 16, 2021 at 09:32 PM

make sure when you jump set running in the animator to false it is taking priority. set it to true when landed. i feel the best way to this is with an isGrounded bool and to dissable running when it is false

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

174 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

2D Animation frame selection 0 Answers

Having some stuck issues on the 2D infinite runner 0 Answers

How do you add a timed animation 1 Answer

Stuttering in simple 2D game using interpolation? 1 Answer

2D animation issue 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges