Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 73321b98cd | |||
| 0b266784fb |
+27
-17
@@ -5,8 +5,8 @@ using System.Collections;
|
||||
[Serializable]
|
||||
public class CameraVehicle : MonoBehaviour
|
||||
{
|
||||
public float sensitivityX = 20F;
|
||||
public float sensitivityY = 20F;
|
||||
public float sensitivityX = 45F;
|
||||
public float sensitivityY = 45F;
|
||||
|
||||
public float minimumX = -360F;
|
||||
public float maximumX = 360F;
|
||||
@@ -14,31 +14,29 @@ public class CameraVehicle : MonoBehaviour
|
||||
public float minimumY = -90F;
|
||||
public float maximumY = 90F;
|
||||
|
||||
public float moveSpeed = 0.25f;
|
||||
public float moveSpeed = 0.125f;
|
||||
|
||||
float rotationX = 0F;
|
||||
float rotationY = 0F;
|
||||
|
||||
Quaternion originalRotation;
|
||||
|
||||
bool moveCam = false;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if(Input.GetKeyDown(KeyCode.LeftAlt) && Screen.lockCursor == false)
|
||||
{
|
||||
Screen.showCursor = false;
|
||||
Screen.lockCursor = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Input.GetKeyDown(KeyCode.Escape))
|
||||
moveCam = Input.GetKey(KeyCode.LeftAlt);
|
||||
|
||||
if(!moveCam)
|
||||
{
|
||||
Screen.lockCursor = false;
|
||||
Screen.showCursor = true;
|
||||
}
|
||||
if(Screen.lockCursor == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Screen.showCursor = false;
|
||||
Screen.lockCursor = true;
|
||||
}
|
||||
|
||||
rotationX += Input.GetAxis("Mouse X") * sensitivityX;
|
||||
@@ -52,6 +50,17 @@ public class CameraVehicle : MonoBehaviour
|
||||
|
||||
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 direction = Vector3.zero;
|
||||
if(Input.GetKey(KeyCode.W))
|
||||
@@ -70,11 +79,11 @@ public class CameraVehicle : MonoBehaviour
|
||||
{
|
||||
direction += Vector3.left;
|
||||
}
|
||||
if(Input.GetKey(KeyCode.Space))
|
||||
if(Input.GetKey(KeyCode.E))
|
||||
{
|
||||
direction += Vector3.up;
|
||||
}
|
||||
if(Input.GetKey(KeyCode.LeftShift))
|
||||
if(Input.GetKey(KeyCode.Q))
|
||||
{
|
||||
direction += Vector3.down;
|
||||
}
|
||||
@@ -82,7 +91,8 @@ public class CameraVehicle : MonoBehaviour
|
||||
{
|
||||
direction *= 2;
|
||||
}
|
||||
pos += transform.rotation * direction * moveSpeed;
|
||||
Quaternion movrot = Quaternion.Euler(0f, transform.localEulerAngles.y, 0f);
|
||||
pos += movrot * direction * moveSpeed;
|
||||
transform.position = pos;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user