I’m building a simulation of satellites orbiting Earth. The simulation requires a high level of accuracy. I use real-world scale values for physics calculations, and then scale them down for Unity.
The operative code:
public void FixedUpdate()
{
// Calculate gravity using Fg = G*m1*m2/r^2. Result is scaled down for Unity
float gravity = G * massEarth * massSat / Distance() / Distance();
gravity = gravity / meterScale * timeScale * timeScale;
Vector3 gravityVector = (GravityDirection() * gravity);
_rigidbody.AddForce(gravityVector);
}
In a perfect world the distance of a satellite in circular orbit should not change, so the goal is to minimize |position(t) - position(0)|.
The problem: because I am scaling the force by a time scale (in my own calculations, not using Time.timeScale), the satellite moves a significant distance in between FixedUpdate calls, and error accumulates. I need FixedUpdate to run more frequently.
The solution: I am able to reduce error to acceptable levels by setting Time.fixedDeltaTime to 0.005, though 0.0005 would be ideal.
My question: As a result of setting fixedDeltaTime so low, what kind of performance issues should I expect as I scale my scene by adding more satellites and custom assets? Is it advisable to use an alternate way of increasing frequency of physics updates?
The target device will be Hololens.