Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Addforce is pushing the rigidbody with different force!

Discussion in 'Scripting' started by Mystique, Nov 25, 2014.

  1. Mystique

    Mystique

    Joined:
    Nov 19, 2014
    Posts:
    40
    Currently using this line of code for Jumping
    Code (JavaScript):
    1.   rigidbody.AddForce(0, jumpVelocity, 0,);
    My rigidbody looks like this


    : te.PNG

    I've been doing some tests and can't figure out whats going on, I know rigidbody has its own physics and such and friction can cause acceleration onto the rigidbody, but I didn't think just pressing jump on the spot would create drastically different jump heights on occasion. Can someone help with this, is there a specific force I need to apply for position changing or a dampener that can stop this effect?
     
  2. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    one line of code will get you no help.
     
  3. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    What do you use in order to trigger the jump? GetKey /GetButton? GetKeyDown /GetButtonDown?

    Like @JamesLeeNZ posted, you have to provide more information.

    It has probably something to do with the ForceMode and the way you trigger the jump input.