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

Real cube scale

Discussion in 'Scripting' started by none3d, Apr 15, 2021.

  1. none3d

    none3d

    Joined:
    Mar 4, 2021
    Posts:
    168
    What is the true scale of a cube in unity3D?
    Is 1 meter by 1 meter by 1 meter?
     
  2. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    The primitive cube at scale (1,1,1) is 1x1x1 units, yes. By default for the physics engine, that means meters, but it doesn't have to be. You could decide 1 Unity unit is 1cm if you're not using rigidbodies or adjust physics properties to suit.
     
    none3d and Joe-Censored like this.
  3. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    It's one arbitrary unit for most purposes, you can name it what ever you like (meter, cm, km, mile, feet, smoot, lightyear, etc.)

    Like @Schneider21 said the physics is going with the heuristic that 1 unit is one meter, or more correctly (imo) - that the system is metric (base 10).

    If you decide that 1 unit is a km instead of a meter (conventionally) and you drop a rigidbody you don't have to adjust anything to make the simulation "correct", it already is.
    If you're going with a system that has weird conversions within itself you're gonna have some problems (not trying to start a fight about metric vs imperial, but imperial for example isn't base anything)
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Just something I've noticed on the physics scale discussion, often I've seen realistic physics behavior can actually look wrong during gameplay even though it is correct. When you're dealing with big things, big ships, big buildings, etc, correct physics can actually look like things are falling far too slowly.

    Unless you're doing a realism based simulation, for a game usually it is more important for things to feel right to the player and to feel fun, than for the physics behavior to match actual earth gravity behavior. Don't be afraid to play with all this stuff until it feels best.

    You're no fun ;)
     
  5. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    Totally, my gravity is usually around 15-20 ms to get something that "feels" real.
    The default 9.81 is totally realistic (as far as newtonian gravity go) but it feels super "floaty".
     
    Joe-Censored likes this.
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    Yes, I find this too for a lot of external third-person or distant-view games.

    One counterpoint was when I first was working on my first person Jetpack Kurt Space Flight game, even very low gravity (1 or 2 m/s^2) was too much. The controls were such that it took the average user a long time to orient the craft meaningfully, and if the gravity was too high, dead user.

    Over time as I expanded the controls and stability systems, and refined the input filtering to be much more streetable, I was able to have gravity ranging from 0.5 m/s^2 all the way up to 25 m/s^2.

    The 25 m/s^2 gravity is totally flyable, but brutally unforgiving.

    In other news, here was me doing some acrobatic testing, trying to do loops and spins. This video is shot with 6 m/s^2 gravity and 2x main motor (eg, 12 m/s^2 main motor with zero fuel weight, less with fuel obviously):



    A lot of the test runs didn't go well.
     
    SparrowGS and Joe-Censored like this.
  7. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    Changing your scale means you also need to change your accelerations (including acceleration due to gravity), because acceleration uses units of squared-distance instead of just distance. It's not scale-invariant.

    (Of course, there are various reasons you might adjust the gravity even if you're not changing your scale. But any time you intentionally switch to a new scale, you should adjust gravity to compensate.)
     
    none3d and Joe-Censored like this.
  8. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    I'm not sure I understand what you mean, what I meant is that if you put an object X units above a plane with a gravity of Y, it doesn't matter if you use meters, cm or km (mili, giga, etc too) the scale you apply to the X variable you need to also apply to the Y variable
    so if you had 100 meters above the plane with a gravity of 9.81m/s and you decide to call it km you now effectively have an object 100km above ground and a gravity of 9.81km/s.

    Sure if you wanna use km and have a 9.81m/s gravity you need to use .00981 for the gravity, but if you just wanna call the units by a different (metric :p) name the physics should be "correct", no?
     
    none3d likes this.
  9. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    Linear motion physics yes, but not gravity, which is an acceleration.

    Think of it this way: if gravity remains constant, if you leap off a 1-meter high building versus a 10-meter high building with a camera pulled back far enough that it looks the same, you're gonna take more time to accelerate down and hit the ground. Try it, you'll see!

    That's why you would need to scale the gravity up accordingly.
     
  10. Owen-Reynolds

    Owen-Reynolds

    Joined:
    Feb 15, 2012
    Posts:
    1,992
    Suppose you have a 1 unit tall, narrow block and you let it tip over. Unity's gravity will make it look like a not-very-tall block falling over, from the speed it falls. If you tell your cat "now this building is a kilometer tall because 1 unit = 1 kilometer" and do the same thing, obviously it will fall over the same way, still looking like a not-very-tall block. Unity physics thinks 1 unit = 1 meter unless you change gravity.

    Or.in your way of saying it, it looks exactly like a 1 kilometer tall building tipping over on a planet where gravity is a massive 9.8 kilometers/s/s. If you're on earth, the gravity setting times the units has to come out to about 9.8 meters/s/s (which is ballpark, anything around there may look better).
     
  11. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    First, I'd like to note that acceleration due to gravity is not 9.8 m/s, it's 9.8 m/s^2. Accelerations are distance / (time * time). Just (distance / time) would be speed, not acceleration.

    Secondly, if having your gravity be a thousand times stronger than normal doesn't count as "incorrect", then I'm not sure what you mean by "correct". 9.8 km/s^2 = 9800 m/s^2 = gravity is a thousand times as strong as on Earth.

    I mean, the physics are still "correct" in the sense that you could have that amount of gravity, hypothetically, somewhere. By that standard, any possible number you put in for gravity would be "correct".

    But it won't match Earth's gravity.


    The key thing to notice is that a 1-meter cube placed 100 meters above the ground and a 1-kilometer cube placed 100 kilometers above the ground will take different amounts of time to fall down and hit the ground (if you place them both in the same gravity). So you can tell whether the camera is zoomed in close to a small thing or zoomed out far away from a big thing based on how quickly it falls.

    And it's not just gravity, it's all acceleration. Big things take longer to get moving (in relative terms). You can make a player intuitively think that something is bigger or smaller just by changing how fast it accelerates.
     
  12. Owen-Reynolds

    Owen-Reynolds

    Joined:
    Feb 15, 2012
    Posts:
    1,992
    But that's an art thing, not a math thing. We know massive ships tend to take longer to get going compared to a similar smaller ship. We can use that it we only see part of a ship leaving. But it would look fine for a battleship to out-accelerate a row-boat.

    If Godzilla tosses an army tank it can accelerate pretty fast -- Godzilla is strong. But math says it can't start to fall too quickly or we'll realize its really a toaster-sized car.

    For anything except gravity, you can say it's 10x bigger and the tractor beam.engine/spell is 10x as strong
     
    Joe-Censored and none3d like this.
  13. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    And.... this is why I love making and talking about games and the games industry.

    I remember a time 25+ years ago at Interplay we were all sitting around debating what set of abilities to put into some characters: lasers, guns, axes, etc., and one of the guys looked around the table and said something to the effect of, "Guys, listen to what we're talking about! This is our job! This is amazing!"
     
    SparrowGS and Joe-Censored like this.
  14. Owen-Reynolds

    Owen-Reynolds

    Joined:
    Feb 15, 2012
    Posts:
    1,992
    But I also remember almost the opposite. Mostly young guys were talking about realistic limb-severing and blood spurts with radioactive chainsaws, and some of the older guys were saying the new frontier was saving a lost puppy or, maybe collecting gems (and everyone looked at the one woman, who was busy drawing a dragon using the chainsaw).

    Most games seem better with an unrealistic world. Hand-code gravity so safes fall faster than flowerpots, since it's cool. Have attacks shove you harder and faster as you're wounded. In a platformer where you play a blob no one is even thinking whether you're an inch tall, a toot, 10 feet. Gravity has no math basis there -- it's purely determined by how far you want jumps to go. High gravity could kick-in after a bit, like a Road Runner cartoon.
     
    Joe-Censored and Kurt-Dekker like this.