anti jiggle

This commit is contained in:
ntr committed 2023-08-04 14:59:24 +10:00
1 parent ea42894443
commit d97efd0e88
1 file changed
+6 -2
+6 -2
View File
@@ -69,11 +69,12 @@ public class ShipControls : MonoBehaviour, SpaceRaceInput.IShipActions {
input.ship.RemoveCallbacks(this);
}
void Update() {
// to minimise input lag we poll for the thrust vector every frame and set it
thrust = getThrust();
// if (rigidBody.velocity.magnitude < 0.5f) rigidBody.velocity = Vector3.zero;
// same with the camera, we always look around
UpdateCamera();
}
@@ -97,7 +98,10 @@ public class ShipControls : MonoBehaviour, SpaceRaceInput.IShipActions {
// not being done by a force because of strange behaviour
// needs investigation
float step = stabliseMag * Time.fixedDeltaTime;
rigidBody.rotation = Quaternion.RotateTowards(transform.rotation, aim.transform.rotation, step);
// stop the ship jiggling because of micro camera movement
if (Quaternion.Angle(aim.transform.rotation, rigidBody.rotation) > 1f)
rigidBody.rotation = Quaternion.RotateTowards(transform.rotation, aim.transform.rotation, step);
}
void UpdateCamera() {