Search Unity

Trying to create a jump animation. Need help!

Discussion in '2D' started by gooff, Nov 7, 2021.

  1. gooff

    gooff

    Joined:
    Oct 20, 2021
    Posts:
    5
    so I'm making a square spin while it jumps. The biggest problem I'm facing is that the square's animation seems to interact with gravity. So if I jump in place, the square seems to spin perfectly fine and then comes back to ground. But when I try jumping left or right, instead of just playing the animation as it moves left or right in air, the square starts moving in weird unexpected ways when I press left or right. When I turn off the animation and jump, everything's fine.

    I'm using ForceMode2d.Impulse to jump. So according to my assumption its just a force that happens and goes away instead of constantly applying the force in which case the weird animation might make sense.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,748
    Things to isolate:

    - does the jumping work properly when animation is removed?

    - is the jumping using world coordinates (eg Vector3.up) or local coordinates (transform.up)

    - also check what you're animating. If you want to animate a physics object, generally you want to only animate children of the Rigidbody, NOT the actual rigidbody itself, for obvious reasons.
     
  3. awaisiscool2

    awaisiscool2

    Joined:
    Aug 25, 2021
    Posts:
    8
    Yes the jump is perfectly fine when animation is removed.

    Yes I am using Vector3.up for jumping.

    It's just a square so it doesn't have any children, it's a rigidbofy as a whole.

    Tho I still don't know what to try when I get back home. Does your first point imply that generally the torso of a character is rigidbody-id and the rest if the body parts constitute the animations?
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    Did you change your user ID?
     
  5. awaisiscool2

    awaisiscool2

    Joined:
    Aug 25, 2021
    Posts:
    8
    Hmm....that's weird I don't remember doing that l. But yeah why are the names different?
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    You've logged on as a user you created Aug 25 and not the user create on Oct 20 by the looks of it.