track limits

This commit is contained in:
ntr committed 2023-07-02 14:42:31 +10:00
1 parent 2cc43a3515
commit d7672612cc
3 files changed
+13629 -142

No files matched your search

File diff suppressed because it is too large. Load diff
+16 -14
View File
@@ -17,8 +17,8 @@ public class ShipControls : MonoBehaviour {
ForceMode m_forceMode;
// Camera Controls
float m_mouseH = 0.5f;
float m_mouseV = 0.5f;
float m_mouseH = 1.0f;
float m_mouseV = 1.0f;
float m_camYaw = 0.0f;
float m_camPitch = 0.0f;
@@ -67,12 +67,14 @@ public class ShipControls : MonoBehaviour {
}
Vector3 getThrust() {
// thrust
// thrust in the direction of the camera
if (Input.GetMouseButton(0))
// transform from the camera's forward vector into world space
return m_camera.transform.TransformDirection(Vector3.forward) * m_thrustMag;
// brake
// brake just decelerates the ship against the direction it is moving
if (Input.GetMouseButton(1)) {
// the velocity is already in world space so we just invert it
return m_rigidBody.velocity.normalized * -1f * m_thrustMag;
}
@@ -80,8 +82,8 @@ public class ShipControls : MonoBehaviour {
}
// 2D strafing
// TODO add multiplier
// combine
// we combine all the vectors so you can move in 2 dimensions at once
// thrust is added as a relative force so we don't need to convert to worldspace
Vector3 getStrafe() {
Vector3 strafe = new Vector3(0.0f, 0.0f, 0.0f);
@@ -105,14 +107,14 @@ public class ShipControls : MonoBehaviour {
if (Input.GetKey(KeyCode.Space))
Respawn();
if (Input.GetKey(KeyCode.Alpha1))
m_forceMode = ForceMode.Acceleration;
if (Input.GetKey(KeyCode.Alpha2))
m_forceMode = ForceMode.Impulse;
if (Input.GetKey(KeyCode.Alpha3))
m_forceMode = ForceMode.Force;
if (Input.GetKey(KeyCode.Alpha4))
m_forceMode = ForceMode.VelocityChange;
// if (Input.GetKey(KeyCode.Alpha1))
// m_forceMode = ForceMode.Acceleration;
// if (Input.GetKey(KeyCode.Alpha2))
// m_forceMode = ForceMode.Impulse;
// if (Input.GetKey(KeyCode.Alpha3))
// m_forceMode = ForceMode.Force;
// if (Input.GetKey(KeyCode.Alpha4))
// m_forceMode = ForceMode.VelocityChange;
if (Input.GetKey(KeyCode.F10))
Application.Quit();