Search Unity

Problem with RigidBody 2D and Gravity

Discussion in 'Getting Started' started by avinsinanan, Mar 11, 2017.

  1. avinsinanan

    avinsinanan

    Joined:
    May 23, 2016
    Posts:
    44
    Hi,

    I made a simple 2d sprite animation and applied a RigidBody 2D to it in the Inspector. I rigid body left the Gravity as 1 (I am assuming 1 represents the 9.81 m/s2). Also I saw someone leave it as 1 in an online tutorial and it worked fine for them. I posted a pic of what I did below in the email -

    Anyway I experienced two problems -

    1. When the value is 1 my character falls very very slowly to the ground very very slowly. I know what you are thinking, I should change it to 10. However if I do this it does fall normally like in real life... but.. which brings me to 2...

    2. I want to apply a upward force to make the character jump, which means I have to apply a huge force like 2000 (when using ADD FORCE 2D) when g = 10.

    Also when the force is so high the character just JUMPS so fast he just reaches the highest point so fast you does see him move in between.. what could I possibly be doing wrong.. on the online tutorials I am following exactly what they did and for me its just not working ... any ideas?

    upload_2017-3-11_12-39-1.png
     
  2. SarfaraazAlladin

    SarfaraazAlladin

    Joined:
    Dec 20, 2013
    Posts:
    280
    Sounds like your object has a huge scale.

    Remember - large objects appear to fall slowly, simply because you have to view them from very far away to see them moving.

    How big is your object beside a primitive cube that's 1 x 1 x 1?
     
  3. avinsinanan

    avinsinanan

    Joined:
    May 23, 2016
    Posts:
    44
    Hello, SarfarazzAlladin,

    I posted a picture below to compare my character (which is a snake) coompared to a 1x1x1 cube. The cube is black. The cube falls normal when a gravity of 1 is applied btw :s .. any ideas again?

    upload_2017-3-11_13-30-3.png
     
  4. SarfaraazAlladin

    SarfaraazAlladin

    Joined:
    Dec 20, 2013
    Posts:
    280
    So, I was way off base with my first assumption:confused: Sorry about that!

    I guess the only other thing I can think of is your animation. Is it possible that its messing with the y position of the character? Does the character fall normally when you strip away the playmaker + anim stuff?

    Try disabling one component at a time maybe and try to isolate where the trouble is coming from.
     
  5. avinsinanan

    avinsinanan

    Joined:
    May 23, 2016
    Posts:
    44
    SarfarazzAlladin,,

    Well you were right. It was the the Playmaker Script Component. But why? I mean My script is a very very simple playmaker script and has NOTHING to do with gravity... why would it affect the gravity...????? plus i need the playmaker script AHHH this is so confusing
     
  6. SarfaraazAlladin

    SarfaraazAlladin

    Joined:
    Dec 20, 2013
    Posts:
    280
    I'm sure you'll find the problem :) Do the same sort of investigation on your playmaker script. Disconnect one node at a time between testing to narrow down where the trouble is coming from.
     
  7. avinsinanan

    avinsinanan

    Joined:
    May 23, 2016
    Posts:
    44
    hey I figured it out. In the playmaker script I had to unckeck the vector option in set Velcoity 2D... it took me over an hour sigh .. but thanks very much for the advice SafaraazAlladin .. muchas gracia
     
    SarfaraazAlladin likes this.
  8. laffan

    laffan

    Joined:
    Aug 20, 2018
    Posts:
    3
    Thank you SO MUCH for posting this. I'd just finished my own hour of wondering what the F was going on.
     
  9. SallyEde

    SallyEde

    Joined:
    Apr 6, 2020
    Posts:
    1
    Same issue, using same tutorial! Thank you for posting your solution !