- Home /
 
Any solution For extreamly large gameworlds [Single Precision Problem]
In my Game I require a working space of preferably around a few hundred Km. Looking at previous Questions the answers given are usually either Scale down the scene or use some form of spacial partitioning [breaking down the space into smaller chunks].
At standard scale under 10,000 is mostly jitter free
Unless I'm doing something wrong scaling down the scene doesn't seam to fix anything as if I scale down everything by 100, the "jitter point" just appears 100 times closer so I'm stuck with the same overall world size.
If I go the spacial partitioning route and assuming and I don't have the chunks overlapping [which would make the transitions smoother] increasing the size of the scene cubes for each extra layer 10,000 = 1, 50,000 = 27 , 90,000 = 125 chunks which is an insane number of chunks for the size I require.
Assuming there is a way to convert the Vector3's to double precision floats I would have an insane workspace before the "jitter point" appears [~30au or the distance from the sun to Neptune!!]
SO is there any way to use double precision vector3's or some method I haven't found to allow unity to create Scenes the size I require
I've read one solution - though not sure where - to have the scene move around the camera, which remains near the origin. If you think this is a possibility for your project, it might be worth having a search around. (Scotty: Imagine that! It never occurred to me to think of SPACE as the thing that was moving!)
Thanks for the idea, I've Come up with a solution based on it below.
Answer by Lord Simpson · Mar 28, 2011 at 10:31 AM
Ok ive come up with the following Idea, Any comments / improvements are welcome
    if (check) {
        float dist = Vector3.Distance (transform.position, Vector3.zero);
        if ( dist > 8000f) {
            foreach (GameObject obj in Object.FindObjectsOfType (typeof(GameObject)))                   
                if (obj != gameObject && obj.transform.root != transform.root && obj.layer != 10 && obj.transform == obj.transform.root)                    
                    obj.transform.position -= transform.position;
            transform.position = Vector3.zero;
        }
        checkpoint = ((8000f - dist) / 600f);
        timer = 0;
        if (checkpoint > 0.5f)
            check = false;
    } else {
        if (timer > checkpoint) {
            check = true;
        }
    }
    timer += Time.deltaTime;
 
                
                
               Basically it moves the entire world bar anything that is part of the game object this is attached to or anything on layer 10 which I have called "GlobalPosition" but only does this when the player is half a second from the 8km border at top speed.
Also this seams to have good performance, my pc can cope with ~1024 "rigid cubes" with no noticeable hiccup when travelling over the border
Just Updated The code, basically had to add "&& obj.transform == obj.transform.root" to the check or it would move all the children of objects massively out of alignment
Your answer