Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Issues with 2D sprite jumping

Discussion in '2D' started by ULSK12, Mar 24, 2023.

  1. ULSK12

    ULSK12

    Joined:
    Feb 21, 2020
    Posts:
    1
    01.png

    Hello,

    I'm just starting out Unity and I've been trying to get the player character to enter a jump animation. I have most of the framework done and the player does jump, but the jump animation is always delayed in some way.

    The animation is supposed to transition from "player-idle-temp" to "player-jump" when "isWalking" is false and "isJumping" is true, but even when those conditions are met the transition does not happen immediately as shown in the image, and sometimes it won't go off at all before the character reaches the ground. The same applies when it tries to go from walking to jumping. How can I solve this?
     
  2. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    599
    There's got to be an issue with the transition to the jump state. Make sure there's no exit time, and the only condition is that "isJumping" is true.

    If you can't figure it out, please post a screenshot of the transition settings.

    Also, you may want to watch this video at some point:



    With sprites, there's no way to smooth transitions, so you don't need complex transitions with their own individual settings at all. It's much easier and cleaner to control everything through code.

    You can play an animation without any animator transitions using this code:
    GetComponent<Animator>().Play("State Name");
     
    Last edited: Mar 24, 2023
  3. Autoface

    Autoface

    Joined:
    Sep 23, 2013
    Posts:
    112
    I dont have a jump animation in my game but you can try the same approach I used here:
    upload_2023-3-24_21-59-49.png
    - Select the transition
    - Has Exit Time to false
    - Then reduce the blend/transition time
     

    Attached Files: