Announcement

Collapse
No announcement yet.

Is the gravity for objects with physics enabled too low?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Is the gravity for objects with physics enabled too low?

    Hello,

    I always had the feeling that meshes with "simulate physics" enabled are somewhat too slow accelerating in world z-direction (gravity). But now I tested it. In the tick-event, if gravity is enabled, it should be

    v2 = v1 + DeltaTime*Gravity

    and the world offset is

    s = v2 * DeltaTime.

    Where Gravity = (0, 0, -980).

    With my understanding for physics this should apply gravity to the object and accelerate it towards the ground. I placed one actor with this in the tick-event besides another actor with simulated physics and enabled gravity. The second actor is much slower accelerating and this can't be only because of different numerical precision. For this the difference is too high.

    Is there a bug in the physics engine or is there a bug in my equations?

    Thanks,

    Thilo

    #2
    Well.... first thing to look at is unit of measure.
    Gravity is 9.8m/s so thats your 980, cm.
    But is this accurate in the space you are implementing it in, or should it have an extra 0 to be correct? 9800 mm?
    Usually the units are cm, so 980 *should* be correct, but practice may prove otherwise.

    Second.
    apply it directly. Just the result of v2 is enough.
    There is no need to scale v2 by delta again, since the result of v2 is already the translated vector by frame speed based on gravity.

    Third. With simulate physics the gravity speed implementation is fairly accurate, however it is like being in a vacuum the whole time, so keep that in mind.
    object mass affects how items move/how much force is needed to get them to move.
    Dropping objects of different size doesn't apply any effect on physics by default anyway.
    Last edited by MostHost LA; 07-21-2020, 02:18 PM.

    Comment


      #3
      Originally posted by MostHost LA View Post
      Well.... first thing to look at is unit of measure.
      Gravity is 9.8m/s so thats your 980, cm.
      But is this accurate in the space you are implementing it in, or should it have an extra 0 to be correct? 9800 mm?
      Usually the units are cm, so 980 *should* be correct, but practice may prove otherwise.

      Second.
      apply it directly. Just the result of v2 is enough.
      There is no need to scale v2 by delta again, since the result of v2 is already the translated vector by frame speed based on gravity.

      Third. With simulate physics the gravity speed implementation is fairly accurate, however it is like being in a vacuum the whole time, so keep that in mind.
      object mass affects how items move/how much force is needed to get them to move.
      Dropping objects of different size doesn't apply any effect on physics.
      I made a mistake in my formula. It is s = v1 * DeltaTime + Gravity * DeltaTime²/2. After that I can update the velocity to v2 = v1 * Gravity. With that, it reaches almost the same velocity like the object with physics enabled. But there seems to be a small delay before the physics object starts accelerating. About 0.42 seconds. If I start the acceleration on my object after with that delay, it will hit the ground at the same time like the physics object.

      Comment


        #4
        thats because it takes a bit for the engine to realize the item needs to be dropped.

        Try linking both items to the same button press.

        Best situation to have it even is to duplicate the input and disable the consume input so that both nodes can be applied in tandem.

        Hook a simulate physics enabled on one. And a boolean to start the ontick process for the other.

        You can do this on the level bp.

        At runtime you should not have the initial delay - but again, practice may prove me wrong.

        Comment


          #5
          Hi, just tested it (one physics simulated one manually on tick) and they behave the same.

          Click image for larger version

Name:	annotation_2020_07_21.jpg
Views:	93
Size:	93.2 KB
ID:	1791125

          v2 = v1 + DeltaTime*Gravity

          and the world offset is

          s = v2 * DeltaTime.

          Where Gravity = (0, 0, -980).
          This works if you implement it correctly.

          It is s = v1 * DeltaTime + Gravity * DeltaTime²/2. After that I can update the velocity to v2 = v1 * Gravity.
          Yes you can also do it via the acceleration, but then v2 = v1 + Gravity*DeltaTime. Generally it is always a good idea to look at the units when doing physical computations. The unit of distance is cm (normally it would be meters, but since UE uses centimeters...), the unit of velocity is cm/s (centimeter per second), the unit of time is s (second) and the unit of acceleration is cm/s2 (centimeter per square second)

          So if you would do v2 = v1 * Gravity you would get cm/s = cm/s * cm/s2 and those are not equal, therefore the equation is wrong.

          Comment


            #6
            Originally posted by chrudimer View Post
            Hi, just tested it (one physics simulated one manually on tick) and they behave the same.

            Click image for larger version

Name:	annotation_2020_07_21.jpg
Views:	93
Size:	93.2 KB
ID:	1791125



            This works if you implement it correctly.



            Yes you can also do it via the acceleration, but then v2 = v1 + Gravity*DeltaTime. Generally it is always a good idea to look at the units when doing physical computations. The unit of distance is cm (normally it would be meters, but since UE uses centimeters...), the unit of velocity is cm/s (centimeter per second), the unit of time is s (second) and the unit of acceleration is cm/s2 (centimeter per square second)

            So if you would do v2 = v1 * Gravity you would get cm/s = cm/s * cm/s2 and those are not equal, therefore the equation is wrong.
            Yes, I actually had v2 = v1 + Gravity*DeltaTime, not v2 = v1*Gravity.
            It works when I activate the tick of the first and the simulate physics of the second after a short delay (1s). Then both start falling at exactly the same time. Maybe the physics engine needs some time for initialization.

            Comment


              #7
              Maybe the physics engine needs some time for initialization.
              When I directly spawn them on event begin play then the physics object has a small delay, too before falling down.

              Comment

              Working...
              X