anti jiggle

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