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

Bug Rigidbody2D wrong behavior

Discussion in 'Editor & General Support' started by zh4r0naX, Sep 16, 2022.

  1. zh4r0naX

    zh4r0naX

    Joined:
    Oct 30, 2016
    Posts:
    71
    Hello, my rigidbody2d is not reacting correctly to the applied gravityscale.

    What i wanted to achieve was to apply gravity for a short time to a rigidbody2d. Sadly it somehow goes into the full wrong direction. Iam using Unity2019.4.40f1

    while there are 3 different behaviors without changing any setting.
    What iam doing is setting the rb2d gravity scale to 80. The project has a gravity of (0.0, -9,81). Normally the gravityscale is 0.

    1. When i run into the pit without doing anything before. The player gets sucked into a positive Y Value.
    2. When i open the prefab of the player in the editor, it tries to go up but then the player keeps falling.
    3. When i open the player instance in the scene, the rigidbody acts normally.



    playerCore.rb2d.gravityScale = 80; When animation starts
    playerCore.rb2d.gravityScale = 0; When animation ends.

    Maybe iam missing something?
    Oh yes i was missing something. Turning off "Apply root motion" for the duration of the fall brings the right behavior.

    but honestly this rootmotion thing is making so many things super hard. I guess i dont fully understand what its needed for, i just need it in some animations.

    Thank you for your time, the thread can be closed
     
    Last edited: Sep 16, 2022
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    You could also flair it as RESOLVED yourself rather than leaving it BUG. :)