Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Gravity does not correspond to body mass

Discussion in 'Physics' started by yevgen12, Mar 25, 2021.

  1. yevgen12

    yevgen12

    Joined:
    Mar 20, 2021
    Posts:
    5
    I am trying to balance the attached lifting force with the force of gravity acting on the body.

    I use Rigidbody, built-in gravity == 9.8 and AddForce(). Whatever the mass of the body, it breaks off from the surface before the lifting force reaches 9.8 body weight.

    The average value of the coefficient is about 3.5. From the point of view of physics, it is a constant measured in newton/kg or m/(s^2). Why is it so far from 9.8?

    The worst thing is that it changes noticeably.

    I'm new to Unity and so I admit that I made a mistake in the settings, but my search in the documentation did not yield results.
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,428
    Most likely you're applying the force from Update(), instead of FixedUpdate(). Update() is frame rate-dependent. What you describe is a force being applied multiple times between each physics update.

    So for example, if you apply a force of 3.5 N from Update(), it may happen that force is applied (and accumulated) three times before the next physics update. This means that when the physics updates the simulation, it encounters a force of 3.5 x 3 = 10.5 N applied to that rigidbody, thus lifting it.

    The value changes noticeably because, as said, Update runs at the visual frame rate. Some times will be higher, others lower, depending of the visual frame rate fluctuation with respect to the physics rate.

    Always use FixedUpdate() instead of Update() for your physics related stuff. FixedUpdate() runs at a fixed rate in sync with the internal physics update.
     
    yevgen12 likes this.
  3. yevgen12

    yevgen12

    Joined:
    Mar 20, 2021
    Posts:
    5
    Thank you for your quick response!

    I actually use Update(). Your reasoning seems logical. I will try to do as you said, and later I will write here what happened.
     
  4. yevgen12

    yevgen12

    Joined:
    Mar 20, 2021
    Posts:
    5
    Your solution works perfectly.
     
    Edy likes this.