using System; using Godot; namespace Movementtests.player_controller.Scripts; public partial class Mouse : Node3D { [Export(PropertyHint.Range, "0,0.1,0.001,or_greater")] public float Sensitivity { get; set; } = 0.004f; private Node3D _head; private Camera3D _camera; public delegate bool IsDead(); private IsDead _isPlayerDead; public void Init(Node3D head, Camera3D cam, IsDead isDeadFunc) { Input.SetMouseMode(Input.MouseModeEnum.Captured); _head = head; _camera = cam; _isPlayerDead = isDeadFunc; } public void LookAround(Vector2 lookDir) { // Horizontal movement of head float angleForHorizontalRotation = lookDir.X * Sensitivity; _head.RotateY(angleForHorizontalRotation); // Vertical movement of head Vector3 currentCameraRotation = _camera.Rotation; currentCameraRotation.X += Convert.ToSingle(lookDir.Y * Sensitivity); currentCameraRotation.X = Mathf.Clamp(currentCameraRotation.X, Mathf.DegToRad(-90f), Mathf.DegToRad(90f)); _camera.Rotation = currentCameraRotation; } }