using System; using UnityEngine; public class CameraController : MonoBehaviour { private const float moveSpeed = 10f; private const float rotationSpeed = 100f; private void Update() { Vector3 inputMoveDir = new(); if (Input.GetKey(KeyCode.W)) inputMoveDir.z = +1f; if (Input.GetKey(KeyCode.S)) inputMoveDir.z = -1f; if (Input.GetKey(KeyCode.A)) inputMoveDir.x = -1f; if (Input.GetKey(KeyCode.D)) inputMoveDir.x = +1f; Vector3 moveVector = transform.forward * inputMoveDir.z + transform.right * inputMoveDir.x; transform.position += moveVector * (Time.deltaTime * moveSpeed); Vector3 rotationVector = new(); if (Input.GetKey(KeyCode.Q)) rotationVector.y = +1f; if (Input.GetKey(KeyCode.E)) rotationVector.y = -1f; transform.eulerAngles += rotationVector * (rotationSpeed * Time.deltaTime); } }