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 Every time I play the jumping animation, my character goes down in the y-axis

Discussion in '2D' started by n4sseruae, Sep 18, 2023.

  1. n4sseruae

    n4sseruae

    Joined:
    Sep 7, 2023
    Posts:
    1
    I am new to unity, I'm still a beginner and I created a character with some simple walk, run, and jumping animations (without using physics, just animating the character jumping). I ran into this issue where my character keeps going down in the y-axis each time i jump.

    Before jumping:
    upload_2023-9-18_23-48-6.png
    After jumping playing the jump animation:
    upload_2023-9-18_23-49-3.png

    Each time I press the jump button the character will play the jump animation and will decrease the y-axis.
    I made sure that my jumping animation starts and ends in the same position. Any idea on how to fix this?
    Thanks <3
     
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,179
    It's probably the root motion! Try turning that off on the Animator.


    In general, I recommend putting animation (both in 2D and in 3D) as a child of the object that has the Rigidbody and Collider and all that. Then you move the object and have the animation follow. So instead of animating the movement of the jump, you move the rigidbody and have the animation stay still.

    Otherwise all your jumps have the exact same length! It's also very hard to control for the player - think the original 2D Prince of Persia.
     
    DavidTeo likes this.