I’m making a flight simulator and everything is working out fine, but the camera chase is really bugging me. I the camera coded to move away from the plane when I was at a higher speed and move in at a lower speed. The problem is, when the plane goes too fast, the camera moves so far away that the plane is practically unseeable. I considered having a limit for how far the camera could be away from the plane, but then when the plane accelerated beyond a speed that would be in the limit, it wouldn’t really show in the camera chase.
Here is the code that I am using:
Vector3 moveCamTo = transform.position - transform.forward *10.0f + Vector3.up * 5.0f;
float bias = 0.96f;
Camera.main.transform.position = Camera.main.transform.position * bias +
moveCamTo * (1.0f-bias);
Camera.main.transform.LookAt (transform.position + transform.forward * 30.0f);
I want to have the camera move in only when the plane is accelerating and move out only when it is deaccelerating, and when it is at a constant speed, it will return to the original position (move in if it is far out, move away if it is too far in) but I have no idea how to code this.
I’d greatly appreciate any help.