Search Unity

Unpredictable 2D Rigidbody Results

Discussion in '2D' started by LeeDenbigh, Aug 8, 2016.

  1. LeeDenbigh

    LeeDenbigh

    Joined:
    Jul 7, 2014
    Posts:
    48
    Hi, working on a 2D game and I thought using a Rigidbody would be the best thing to use, but the results of the jump just aren't the same every time.

    Here's a video... I just want the jump to be the same every time I press the jump button...



    Can anyone help please?
     
  2. LeeDenbigh

    LeeDenbigh

    Joined:
    Jul 7, 2014
    Posts:
    48
    I figured it out if anyone else needs a solution... I just instead used:
    rigidbody2D.velocity = new vector3(0, 8, 0);
     
  3. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    Ideally you would be using rigidbody2D.AddForce(Vector3.up * jumpStrength, ForceMode2D.Impulse);

    Where jumpStrength = 8f.