Search Unity

(Solved) Getting normal earth-like gravity/physics without changing gravity?

Discussion in 'Physics' started by SkobbejakGames, Oct 18, 2016.

  1. SkobbejakGames

    SkobbejakGames

    Joined:
    Jun 3, 2016
    Posts:
    396
    It seems that Unity's physics isn't set up like normal earth like gravity by default even though gravity is set to 9.81 meters per second by default. No matter the size, mass or drag settings of an object everything always seems to fall in a very floaty manner. I'm trying to create a large stone pillar domino sequence but they always seem to fall and bounce in a very floaty manner almost like they are in a vacuum even though they are set to 0 drag.

    I can't set the gravity for the entire project higher as that messes with lighter objects, how would I go about getting more realistic/earth-like gravity/physics?
     
    jmacallister_unity likes this.
  2. SkobbejakGames

    SkobbejakGames

    Joined:
    Jun 3, 2016
    Posts:
    396
    Im not sure if physics materials have an effect on this situation as they just seem to control bounce and friction when colliding with other objects.
     
  3. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    I too had a similar problem, I was convinced objects didn't fall correctly, all seemed too slow and 'floaty' as you say.
    So I wrote my own simple gravity and position code and applied it to an object. I had a Unity block at 1kg next to another block of 1kg but using my gravity code. both objects at a 100m height and both let drop at the same time. The both fell identically to each other.

    Anyway to cut a long story short I gave up and used Unity physics as it must be correct after all and if it looks too slow or floaty its an optical illusion.
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    The reason things look floaty:

    1. the perspective of the viewport and your 2D screen. This makes it appear as if the object is falling slower than it would for a given object of that size and drag.

    2. Drag. Higher this is, the slower things will be able to move.

    3. Scale. Given 1 meter = 1 unit, Unity is roughly set up for this. So if you are dropping a mountain then it had better have mountain scale to look right.

    Usually, a combination of all 3. IMHO one cannot use real world scales and values, and expect it to look perceptually right given that the scale of an object in an engine is still guesswork thanks to the camera viewport and internal scale of objects. So it's still going to be off, and will need some tweaking by eye. AFAICT it's pretty close though.
     
  5. SkobbejakGames

    SkobbejakGames

    Joined:
    Jun 3, 2016
    Posts:
    396
    1. OK, I know that a 2D screen/viewport won't display physics as accurate as physics in real life in 3d space, but to call this massive difference in movement an "optical illusion" is a bit innacurate. I know that larger objects will also fall slower at first, but due to terminal velocity they will also pick up speed and momentum until they reach their maximum possible falling speed, which doesn't seem to be happening.

    2. Drag adds air resitance, so adding drag wouldn't help the situation it would make it worse, even on 0 drag movement is still too floaty and drag can't be set to a negative value.

    3. I'm not sure why scale should have such a massive effect on an objects physics as I know size would increase its surface area and thus air resistance but mass should also have an effect (unless youre in a vacuum) as you can have a balloon the same size as a mountain but due to its mass and density it wont fall the same way as a mountain would.

    Another thing to take in account is that these giant stone dominos don't just have gravity acting on them but a pushing force as well, which would also increase their falling speed in real life.

    There is a plugin for unity called bullet physics that seems to get past this issue by allowing the gravity to be set on an individual object and not the entire project but it is a bit resource intensive.
     
    Last edited: Oct 19, 2016
    jmacallister_unity likes this.
  6. SkobbejakGames

    SkobbejakGames

    Joined:
    Jun 3, 2016
    Posts:
    396
    I can almost get the desired effect (still a bit innacurate and some forces act a bit wonky) on my giant stone domino pillars by setting gravity to about minus 100 but as stated previously, this messes with other objects that needs to have lighter movement and even messes with stuff like particles, I would literally need to reconfigure everything in my game to work with minus 100 gravity and set drag very high for lighter objects.

    The best solution would be using the bullet physics for unity plugin in moderation for objects that need it and then downgrading other areas of the game such as graphics to keep framerate above 60fps and consistent. But I don't really want to skimp on other parts of the game and just want to check if there might be a different solution.
     
  7. SkobbejakGames

    SkobbejakGames

    Joined:
    Jun 3, 2016
    Posts:
    396
    Okay, bullet physics doesn't seem as resource intensive as I first anticipated as long as you use it sparingly, I think I'll just be using that for the objects that warrant it, thanks for all the replies and sorry if I went off a bit, Im also sorry if I perhaps phrased my problem a bit innacurately as it is more physics forces such as terminal velocity and momentum that I was referring to rather than gravity specifically.
     
    Last edited: Oct 19, 2016
  8. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    Maybe the following video by Bennett Foddy at the GDC will help to explain that aspect better: http://www.gdcvault.com/play/1021921/Designing-with-Physics-Bend-the
     
  9. SkobbejakGames

    SkobbejakGames

    Joined:
    Jun 3, 2016
    Posts:
    396
    Thanks for the link MelvMay, really appreciate it, it should prove quite useful.
     
    MelvMay likes this.
  10. jmacallister_unity

    jmacallister_unity

    Joined:
    Nov 22, 2021
    Posts:
    2
    Okay, prototyping this in AR definitely confirms that the default unity gravity is "floaty". I'm literally holding a rubix cube and an identicall mas and scale rigid-body cube. Dropping both at the same time the (real-world) rubix cube drops 2x the speed of the rigid body. Everything is built exactly to scale in meters.
     
    Last edited: Sep 14, 2023
  11. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    Please don't necropost.

    Saying Unity gravity is "floaty" is like saying that continually adding -9.81/sec to a float value isn't the same as any other code that does the same. The above answers the why you get this perception.

    It's also not Unity Physics, it's PhysX or Box2D. Nothing here makes it special to Unity. Gravity is a basic part of those engines, Unity just allows you to set the value of gravity. :)