Hi!
When I start the game in unity, after about 2 min, the camera starts shaking… (it also starts shaking, when I build it!) but not on the fixed cameras! The game I make is a flight simulator (Unity Flight simulator).
The plane flies about 150 m/s = 300KTS
Flight simulator and rendering or position issues? Sounds like classic floating-point precision issue.
By that time (2min) you could be somewhere past 18000f units from the origin and this means that float might start to slowly loose precision and cause some issues which are invisible closer to the (0,0,0).
Solution? Implement floating origin. It’s basically this:
using UnityEngine;
using UnityEngine.SceneManagement;
public class FloatingOriginCentral : MonoBehaviour
{
public Vector3 Origin = Vector3.zero;
[SerializeField][Min(1)] float _threshold = 100f;
void LateUpdate ()
{
Vector3 camPos = Camera.main.transform.position;
if( camPos.magnitude>_threshold )
{
Debug.Log($"Origin changed by ( {camPos.x} , {camPos.y} , {camPos.z} )");
Origin += camPos;
for( int z=0 ; z<SceneManager.sceneCount ; z++ )
foreach( GameObject go in SceneManager.GetSceneAt(z).GetRootGameObjects() )
go.transform.position -= camPos;
}
}
}
Credits for this neat root iterator idea:
Floating Origin - Unify Community Wiki