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

World scale and floating point issues

Discussion in 'Physics' started by numbers1234, Dec 4, 2021.

  1. numbers1234

    numbers1234

    Joined:
    Jan 5, 2019
    Posts:
    31
    In my game I am playing around with procedural generation, and I am able to run/drive in any direction with buildings and things spawning in based on a seed. I am aware of floating point issues and going too far from the world's origin point, and my question is how does the "scale" of your world effect this? My scale is about 3 times larger than real world scale, does that mean I have 3 times less space to work with? What if I worked with a scale of 1:.25? Would this give me 4 times the space over working with a 1:1 scale? Trying to figure out if rescaling the entire game would be worth it.
     
  2. numbers1234

    numbers1234

    Joined:
    Jan 5, 2019
    Posts:
    31
    I finally found some info on this, looks like scale doesn't matter. Doesn't look like I can delete this thread? Guess I will post the relevant info

    "In floating point, it doesn't matter what your units are. All that matters is the ratio between the largest and smallest numbers you care about. So, for example, let's look at two worlds: Giant World and Tiny World.

    In Giant World, ships can be 1km long and have polys as small as 1m on a side. When they move slow, that's about 1m/sec which is less than 2cm/frame. But, when a ship is sitting at 8,000,000m from the origin, you only get a precision of 1m. 8,000,000.0 + 0.1 == 8,000,000.0 So, a vertex cannot be located at 8,000,000.5 All verts will snap to the nearest meter in world space. The ship will look glitchy and voxelated. Also, trying to move at 10cm/frame won't work. Adding a velocity of 0.1 to 8,000,000.0 will return 8,000,000.0 So the ship won't move at all.

    In Tiny World, ships can be 1m long and have polys as small as 1mm on a side. When they move slow, that's about 1mm/sec which is less than 0.02mm/frame. But, when a ship is sitting at 8,000m from the origin, you only get a precision of 1mm. 8,000.0 + 0.0001 == 8,000.0 So, a vertex cannot be located at 8,000.05 All verts will snap to the nearest millimeter in world space. The ship will look glitchy and voxelated. Also, trying to move at 0.1mm/frame won't work. Adding a velocity of 0.0001 to 8,000.0 will return 8,000.0 So the ship won't move at all.

    So, by resizing everything you haven't really gained anything because all of the ratios are still the same."
     
    Edy likes this.