2 Commits

Author SHA1 Message Date
VIA256 73321b98cd editor: fix mistake in reset keybind 2025-12-15 16:21:18 -08:00
VIA256 0b266784fb make controls better 2025-12-15 16:04:34 -08:00
+28 -18
View File
@@ -5,8 +5,8 @@ using System.Collections;
[Serializable] [Serializable]
public class CameraVehicle : MonoBehaviour public class CameraVehicle : MonoBehaviour
{ {
public float sensitivityX = 20F; public float sensitivityX = 45F;
public float sensitivityY = 20F; public float sensitivityY = 45F;
public float minimumX = -360F; public float minimumX = -360F;
public float maximumX = 360F; public float maximumX = 360F;
@@ -14,31 +14,29 @@ public class CameraVehicle : MonoBehaviour
public float minimumY = -90F; public float minimumY = -90F;
public float maximumY = 90F; public float maximumY = 90F;
public float moveSpeed = 0.25f; public float moveSpeed = 0.125f;
float rotationX = 0F; float rotationX = 0F;
float rotationY = 0F; float rotationY = 0F;
Quaternion originalRotation; Quaternion originalRotation;
bool moveCam = false;
void Update() void Update()
{ {
if(Input.GetKeyDown(KeyCode.LeftAlt) && Screen.lockCursor == false) moveCam = Input.GetKey(KeyCode.LeftAlt);
if(!moveCam)
{ {
Screen.showCursor = false; Screen.lockCursor = false;
Screen.lockCursor = true; Screen.showCursor = true;
return;
} }
else else
{ {
if(Input.GetKeyDown(KeyCode.Escape)) Screen.showCursor = false;
{ Screen.lockCursor = true;
Screen.lockCursor = false;
Screen.showCursor = true;
}
if(Screen.lockCursor == false)
{
return;
}
} }
rotationX += Input.GetAxis("Mouse X") * sensitivityX; rotationX += Input.GetAxis("Mouse X") * sensitivityX;
@@ -52,6 +50,17 @@ public class CameraVehicle : MonoBehaviour
transform.localRotation = originalRotation * xQuaternion * yQuaternion; transform.localRotation = originalRotation * xQuaternion * yQuaternion;
if(Input.GetKeyDown(KeyCode.R))
{
transform.localEulerAngles = Vector3.zero;
transform.position = Vector3.zero;
}
}
void FixedUpdate()
{
if(!moveCam) return;
Vector3 pos = transform.position; Vector3 pos = transform.position;
Vector3 direction = Vector3.zero; Vector3 direction = Vector3.zero;
if(Input.GetKey(KeyCode.W)) if(Input.GetKey(KeyCode.W))
@@ -70,11 +79,11 @@ public class CameraVehicle : MonoBehaviour
{ {
direction += Vector3.left; direction += Vector3.left;
} }
if(Input.GetKey(KeyCode.Space)) if(Input.GetKey(KeyCode.E))
{ {
direction += Vector3.up; direction += Vector3.up;
} }
if(Input.GetKey(KeyCode.LeftShift)) if(Input.GetKey(KeyCode.Q))
{ {
direction += Vector3.down; direction += Vector3.down;
} }
@@ -82,7 +91,8 @@ public class CameraVehicle : MonoBehaviour
{ {
direction *= 2; direction *= 2;
} }
pos += transform.rotation * direction * moveSpeed; Quaternion movrot = Quaternion.Euler(0f, transform.localEulerAngles.y, 0f);
pos += movrot * direction * moveSpeed;
transform.position = pos; transform.position = pos;
} }