diff --git a/Assets/Content/Systems/Input/Controls.inputactions b/Assets/Content/Systems/Input/Controls.inputactions index 7f1c8e3f26..17c170ccc4 100644 --- a/Assets/Content/Systems/Input/Controls.inputactions +++ b/Assets/Content/Systems/Input/Controls.inputactions @@ -15,39 +15,48 @@ "initialStateCheck": true }, { - "name": "Snap Right", + "name": "Vertical Rotation", "type": "Button", - "id": "7608f038-428f-4432-84fb-3d4e80e039df", + "id": "44e7f37c-88c6-4bd4-b0d0-fe0b161cafac", "expectedControlType": "Button", "processors": "", - "interactions": "MultiTap(tapDelay=0.2)", + "interactions": "", "initialStateCheck": false }, { - "name": "Snap Left", + "name": "Horizontal Rotation", "type": "Button", - "id": "f0b5149d-025d-44c7-850b-76eedaa3308b", + "id": "2bb89fc3-b3a6-4fca-a4c6-c48087be1a5c", "expectedControlType": "Button", "processors": "", - "interactions": "MultiTap(tapDelay=0.2)", + "interactions": "Hold(duration=0.4)", "initialStateCheck": false }, { - "name": "Vertical Rotation", + "name": "Mouse Rotation", "type": "Button", - "id": "44e7f37c-88c6-4bd4-b0d0-fe0b161cafac", + "id": "05c11a8a-0897-4250-af8d-089612cbaf7f", "expectedControlType": "Button", "processors": "", "interactions": "", "initialStateCheck": false }, { - "name": "Horizontal Rotation", + "name": "Snap Right", "type": "Button", - "id": "2bb89fc3-b3a6-4fca-a4c6-c48087be1a5c", + "id": "6075863c-a88a-4295-b561-24da4f2042e3", "expectedControlType": "Button", "processors": "", - "interactions": "", + "interactions": "Tap", + "initialStateCheck": false + }, + { + "name": "Snap Left", + "type": "Button", + "id": "c3a693ef-8736-4622-91e9-3b4a48250e9d", + "expectedControlType": "Button", + "processors": "", + "interactions": "Tap", "initialStateCheck": false } ], @@ -63,28 +72,6 @@ "isComposite": false, "isPartOfComposite": false }, - { - "name": "", - "id": "40991a34-2585-4f5c-b857-73d37c971cf1", - "path": "/3", - "interactions": "", - "processors": "", - "groups": "", - "action": "Snap Right", - "isComposite": false, - "isPartOfComposite": false - }, - { - "name": "", - "id": "165d0665-eda2-49e1-a6f3-7895f663a409", - "path": "/1", - "interactions": "", - "processors": "", - "groups": "", - "action": "Snap Left", - "isComposite": false, - "isPartOfComposite": false - }, { "name": "1D Axis", "id": "b95da6e3-4d0a-449d-8d5e-c97b2535ad30", @@ -119,9 +106,9 @@ "isPartOfComposite": true }, { - "name": "1D Axis", - "id": "43e89268-7fdb-412e-8493-4960be911aab", - "path": "1DAxis", + "name": "Left", + "id": "966f1f13-073c-4178-a716-6be9a87cd145", + "path": "OneModifier", "interactions": "", "processors": "", "groups": "", @@ -130,9 +117,9 @@ "isPartOfComposite": false }, { - "name": "negative", - "id": "b48ff774-f40e-48b3-9ae9-757d47308e12", - "path": "/3", + "name": "modifier", + "id": "c62adfd0-5156-4926-9c91-372525a48e7b", + "path": "/ctrl", "interactions": "", "processors": "", "groups": "", @@ -141,15 +128,147 @@ "isPartOfComposite": true }, { - "name": "positive", - "id": "8cc94a0b-c51c-47dc-89be-985f9efd2461", - "path": "/1", + "name": "binding", + "id": "17f6c765-175e-491a-8171-bf06c4b1c5fe", + "path": "/q", + "interactions": "", + "processors": "", + "groups": "", + "action": "Horizontal Rotation", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "Right", + "id": "fe16d086-24d8-4fa4-8f82-5abbbe27e3ed", + "path": "OneModifier", + "interactions": "", + "processors": "Invert", + "groups": "", + "action": "Horizontal Rotation", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "modifier", + "id": "908e0cf0-c70c-4aa0-bd22-8c9a63a99c17", + "path": "/ctrl", "interactions": "", "processors": "", "groups": "", "action": "Horizontal Rotation", "isComposite": false, "isPartOfComposite": true + }, + { + "name": "binding", + "id": "eb5d1172-1f72-42ff-a6e0-8bb4ced70427", + "path": "/e", + "interactions": "", + "processors": "", + "groups": "", + "action": "Horizontal Rotation", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "One Modifier", + "id": "caf05d9f-86a5-4300-8575-77154dd31167", + "path": "OneModifier", + "interactions": "", + "processors": "", + "groups": "", + "action": "Mouse Rotation", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "modifier", + "id": "8cf44a8a-7bbc-489a-ae0a-c3692b0a8eb4", + "path": "/middleButton", + "interactions": "", + "processors": "", + "groups": "", + "action": "Mouse Rotation", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "binding", + "id": "611931f2-395b-4f6b-82f3-fba56553f7b6", + "path": "/delta/x", + "interactions": "", + "processors": "", + "groups": "", + "action": "Mouse Rotation", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "One Modifier", + "id": "ac41db70-e65e-4d9d-bc6a-ac32e65a0263", + "path": "OneModifier", + "interactions": "", + "processors": "", + "groups": "", + "action": "Snap Right", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "modifier", + "id": "17263931-c9fd-4fd0-b166-81f5d8178278", + "path": "/ctrl", + "interactions": "", + "processors": "", + "groups": "", + "action": "Snap Right", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "binding", + "id": "a250103f-a5e1-4ddf-bad3-40f482969ce3", + "path": "/e", + "interactions": "", + "processors": "", + "groups": "", + "action": "Snap Right", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "One Modifier", + "id": "61ddd7b0-7da5-4076-a802-921a5ea88f18", + "path": "OneModifier", + "interactions": "", + "processors": "", + "groups": "", + "action": "Snap Left", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "modifier", + "id": "a0e20945-47bf-40b4-87d8-f710db0d65d3", + "path": "/ctrl", + "interactions": "", + "processors": "", + "groups": "", + "action": "Snap Left", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "binding", + "id": "7af6e38a-fc12-42d9-a3c4-ea5553ef6f6e", + "path": "/q", + "interactions": "", + "processors": "", + "groups": "", + "action": "Snap Left", + "isComposite": false, + "isPartOfComposite": true } ] }, diff --git a/Assets/Scripts/SS3D/Systems/Inputs/Controls.cs b/Assets/Scripts/SS3D/Systems/Inputs/Controls.cs index 1020454e4c..75947cb23c 100644 --- a/Assets/Scripts/SS3D/Systems/Inputs/Controls.cs +++ b/Assets/Scripts/SS3D/Systems/Inputs/Controls.cs @@ -39,39 +39,48 @@ public @Controls() ""initialStateCheck"": true }, { - ""name"": ""Snap Right"", + ""name"": ""Vertical Rotation"", ""type"": ""Button"", - ""id"": ""7608f038-428f-4432-84fb-3d4e80e039df"", + ""id"": ""44e7f37c-88c6-4bd4-b0d0-fe0b161cafac"", ""expectedControlType"": ""Button"", ""processors"": """", - ""interactions"": ""MultiTap(tapDelay=0.2)"", + ""interactions"": """", ""initialStateCheck"": false }, { - ""name"": ""Snap Left"", + ""name"": ""Horizontal Rotation"", ""type"": ""Button"", - ""id"": ""f0b5149d-025d-44c7-850b-76eedaa3308b"", + ""id"": ""2bb89fc3-b3a6-4fca-a4c6-c48087be1a5c"", ""expectedControlType"": ""Button"", ""processors"": """", - ""interactions"": ""MultiTap(tapDelay=0.2)"", + ""interactions"": ""Hold(duration=0.4)"", ""initialStateCheck"": false }, { - ""name"": ""Vertical Rotation"", + ""name"": ""Mouse Rotation"", ""type"": ""Button"", - ""id"": ""44e7f37c-88c6-4bd4-b0d0-fe0b161cafac"", + ""id"": ""05c11a8a-0897-4250-af8d-089612cbaf7f"", ""expectedControlType"": ""Button"", ""processors"": """", ""interactions"": """", ""initialStateCheck"": false }, { - ""name"": ""Horizontal Rotation"", + ""name"": ""Snap Right"", ""type"": ""Button"", - ""id"": ""2bb89fc3-b3a6-4fca-a4c6-c48087be1a5c"", + ""id"": ""6075863c-a88a-4295-b561-24da4f2042e3"", ""expectedControlType"": ""Button"", ""processors"": """", - ""interactions"": """", + ""interactions"": ""Tap"", + ""initialStateCheck"": false + }, + { + ""name"": ""Snap Left"", + ""type"": ""Button"", + ""id"": ""c3a693ef-8736-4622-91e9-3b4a48250e9d"", + ""expectedControlType"": ""Button"", + ""processors"": """", + ""interactions"": ""Tap"", ""initialStateCheck"": false } ], @@ -87,28 +96,6 @@ public @Controls() ""isComposite"": false, ""isPartOfComposite"": false }, - { - ""name"": """", - ""id"": ""40991a34-2585-4f5c-b857-73d37c971cf1"", - ""path"": ""/3"", - ""interactions"": """", - ""processors"": """", - ""groups"": """", - ""action"": ""Snap Right"", - ""isComposite"": false, - ""isPartOfComposite"": false - }, - { - ""name"": """", - ""id"": ""165d0665-eda2-49e1-a6f3-7895f663a409"", - ""path"": ""/1"", - ""interactions"": """", - ""processors"": """", - ""groups"": """", - ""action"": ""Snap Left"", - ""isComposite"": false, - ""isPartOfComposite"": false - }, { ""name"": ""1D Axis"", ""id"": ""b95da6e3-4d0a-449d-8d5e-c97b2535ad30"", @@ -143,9 +130,9 @@ public @Controls() ""isPartOfComposite"": true }, { - ""name"": ""1D Axis"", - ""id"": ""43e89268-7fdb-412e-8493-4960be911aab"", - ""path"": ""1DAxis"", + ""name"": ""Left"", + ""id"": ""966f1f13-073c-4178-a716-6be9a87cd145"", + ""path"": ""OneModifier"", ""interactions"": """", ""processors"": """", ""groups"": """", @@ -154,9 +141,9 @@ public @Controls() ""isPartOfComposite"": false }, { - ""name"": ""negative"", - ""id"": ""b48ff774-f40e-48b3-9ae9-757d47308e12"", - ""path"": ""/3"", + ""name"": ""modifier"", + ""id"": ""c62adfd0-5156-4926-9c91-372525a48e7b"", + ""path"": ""/ctrl"", ""interactions"": """", ""processors"": """", ""groups"": """", @@ -165,15 +152,147 @@ public @Controls() ""isPartOfComposite"": true }, { - ""name"": ""positive"", - ""id"": ""8cc94a0b-c51c-47dc-89be-985f9efd2461"", - ""path"": ""/1"", + ""name"": ""binding"", + ""id"": ""17f6c765-175e-491a-8171-bf06c4b1c5fe"", + ""path"": ""/q"", ""interactions"": """", ""processors"": """", ""groups"": """", ""action"": ""Horizontal Rotation"", ""isComposite"": false, ""isPartOfComposite"": true + }, + { + ""name"": ""Right"", + ""id"": ""fe16d086-24d8-4fa4-8f82-5abbbe27e3ed"", + ""path"": ""OneModifier"", + ""interactions"": """", + ""processors"": ""Invert"", + ""groups"": """", + ""action"": ""Horizontal Rotation"", + ""isComposite"": true, + ""isPartOfComposite"": false + }, + { + ""name"": ""modifier"", + ""id"": ""908e0cf0-c70c-4aa0-bd22-8c9a63a99c17"", + ""path"": ""/ctrl"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Horizontal Rotation"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""binding"", + ""id"": ""eb5d1172-1f72-42ff-a6e0-8bb4ced70427"", + ""path"": ""/e"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Horizontal Rotation"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""One Modifier"", + ""id"": ""caf05d9f-86a5-4300-8575-77154dd31167"", + ""path"": ""OneModifier"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Mouse Rotation"", + ""isComposite"": true, + ""isPartOfComposite"": false + }, + { + ""name"": ""modifier"", + ""id"": ""8cf44a8a-7bbc-489a-ae0a-c3692b0a8eb4"", + ""path"": ""/middleButton"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Mouse Rotation"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""binding"", + ""id"": ""611931f2-395b-4f6b-82f3-fba56553f7b6"", + ""path"": ""/delta/x"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Mouse Rotation"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""One Modifier"", + ""id"": ""ac41db70-e65e-4d9d-bc6a-ac32e65a0263"", + ""path"": ""OneModifier"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Snap Right"", + ""isComposite"": true, + ""isPartOfComposite"": false + }, + { + ""name"": ""modifier"", + ""id"": ""17263931-c9fd-4fd0-b166-81f5d8178278"", + ""path"": ""/ctrl"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Snap Right"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""binding"", + ""id"": ""a250103f-a5e1-4ddf-bad3-40f482969ce3"", + ""path"": ""/e"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Snap Right"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""One Modifier"", + ""id"": ""61ddd7b0-7da5-4076-a802-921a5ea88f18"", + ""path"": ""OneModifier"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Snap Left"", + ""isComposite"": true, + ""isPartOfComposite"": false + }, + { + ""name"": ""modifier"", + ""id"": ""a0e20945-47bf-40b4-87d8-f710db0d65d3"", + ""path"": ""/ctrl"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Snap Left"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""binding"", + ""id"": ""7af6e38a-fc12-42d9-a3c4-ea5553ef6f6e"", + ""path"": ""/q"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Snap Left"", + ""isComposite"": false, + ""isPartOfComposite"": true } ] }, @@ -748,10 +867,11 @@ public @Controls() // Camera m_Camera = asset.FindActionMap("Camera", throwIfNotFound: true); m_Camera_Zoom = m_Camera.FindAction("Zoom", throwIfNotFound: true); - m_Camera_SnapRight = m_Camera.FindAction("Snap Right", throwIfNotFound: true); - m_Camera_SnapLeft = m_Camera.FindAction("Snap Left", throwIfNotFound: true); m_Camera_VerticalRotation = m_Camera.FindAction("Vertical Rotation", throwIfNotFound: true); m_Camera_HorizontalRotation = m_Camera.FindAction("Horizontal Rotation", throwIfNotFound: true); + m_Camera_MouseRotation = m_Camera.FindAction("Mouse Rotation", throwIfNotFound: true); + m_Camera_SnapRight = m_Camera.FindAction("Snap Right", throwIfNotFound: true); + m_Camera_SnapLeft = m_Camera.FindAction("Snap Left", throwIfNotFound: true); // Movement m_Movement = asset.FindActionMap("Movement", throwIfNotFound: true); m_Movement_Movement = m_Movement.FindAction("Movement", throwIfNotFound: true); @@ -846,19 +966,21 @@ public int FindBinding(InputBinding bindingMask, out InputAction action) private readonly InputActionMap m_Camera; private ICameraActions m_CameraActionsCallbackInterface; private readonly InputAction m_Camera_Zoom; - private readonly InputAction m_Camera_SnapRight; - private readonly InputAction m_Camera_SnapLeft; private readonly InputAction m_Camera_VerticalRotation; private readonly InputAction m_Camera_HorizontalRotation; + private readonly InputAction m_Camera_MouseRotation; + private readonly InputAction m_Camera_SnapRight; + private readonly InputAction m_Camera_SnapLeft; public struct CameraActions { private @Controls m_Wrapper; public CameraActions(@Controls wrapper) { m_Wrapper = wrapper; } public InputAction @Zoom => m_Wrapper.m_Camera_Zoom; - public InputAction @SnapRight => m_Wrapper.m_Camera_SnapRight; - public InputAction @SnapLeft => m_Wrapper.m_Camera_SnapLeft; public InputAction @VerticalRotation => m_Wrapper.m_Camera_VerticalRotation; public InputAction @HorizontalRotation => m_Wrapper.m_Camera_HorizontalRotation; + public InputAction @MouseRotation => m_Wrapper.m_Camera_MouseRotation; + public InputAction @SnapRight => m_Wrapper.m_Camera_SnapRight; + public InputAction @SnapLeft => m_Wrapper.m_Camera_SnapLeft; public InputActionMap Get() { return m_Wrapper.m_Camera; } public void Enable() { Get().Enable(); } public void Disable() { Get().Disable(); } @@ -871,18 +993,21 @@ public void SetCallbacks(ICameraActions instance) @Zoom.started -= m_Wrapper.m_CameraActionsCallbackInterface.OnZoom; @Zoom.performed -= m_Wrapper.m_CameraActionsCallbackInterface.OnZoom; @Zoom.canceled -= m_Wrapper.m_CameraActionsCallbackInterface.OnZoom; - @SnapRight.started -= m_Wrapper.m_CameraActionsCallbackInterface.OnSnapRight; - @SnapRight.performed -= m_Wrapper.m_CameraActionsCallbackInterface.OnSnapRight; - @SnapRight.canceled -= m_Wrapper.m_CameraActionsCallbackInterface.OnSnapRight; - @SnapLeft.started -= m_Wrapper.m_CameraActionsCallbackInterface.OnSnapLeft; - @SnapLeft.performed -= m_Wrapper.m_CameraActionsCallbackInterface.OnSnapLeft; - @SnapLeft.canceled -= m_Wrapper.m_CameraActionsCallbackInterface.OnSnapLeft; @VerticalRotation.started -= m_Wrapper.m_CameraActionsCallbackInterface.OnVerticalRotation; @VerticalRotation.performed -= m_Wrapper.m_CameraActionsCallbackInterface.OnVerticalRotation; @VerticalRotation.canceled -= m_Wrapper.m_CameraActionsCallbackInterface.OnVerticalRotation; @HorizontalRotation.started -= m_Wrapper.m_CameraActionsCallbackInterface.OnHorizontalRotation; @HorizontalRotation.performed -= m_Wrapper.m_CameraActionsCallbackInterface.OnHorizontalRotation; @HorizontalRotation.canceled -= m_Wrapper.m_CameraActionsCallbackInterface.OnHorizontalRotation; + @MouseRotation.started -= m_Wrapper.m_CameraActionsCallbackInterface.OnMouseRotation; + @MouseRotation.performed -= m_Wrapper.m_CameraActionsCallbackInterface.OnMouseRotation; + @MouseRotation.canceled -= m_Wrapper.m_CameraActionsCallbackInterface.OnMouseRotation; + @SnapRight.started -= m_Wrapper.m_CameraActionsCallbackInterface.OnSnapRight; + @SnapRight.performed -= m_Wrapper.m_CameraActionsCallbackInterface.OnSnapRight; + @SnapRight.canceled -= m_Wrapper.m_CameraActionsCallbackInterface.OnSnapRight; + @SnapLeft.started -= m_Wrapper.m_CameraActionsCallbackInterface.OnSnapLeft; + @SnapLeft.performed -= m_Wrapper.m_CameraActionsCallbackInterface.OnSnapLeft; + @SnapLeft.canceled -= m_Wrapper.m_CameraActionsCallbackInterface.OnSnapLeft; } m_Wrapper.m_CameraActionsCallbackInterface = instance; if (instance != null) @@ -890,18 +1015,21 @@ public void SetCallbacks(ICameraActions instance) @Zoom.started += instance.OnZoom; @Zoom.performed += instance.OnZoom; @Zoom.canceled += instance.OnZoom; - @SnapRight.started += instance.OnSnapRight; - @SnapRight.performed += instance.OnSnapRight; - @SnapRight.canceled += instance.OnSnapRight; - @SnapLeft.started += instance.OnSnapLeft; - @SnapLeft.performed += instance.OnSnapLeft; - @SnapLeft.canceled += instance.OnSnapLeft; @VerticalRotation.started += instance.OnVerticalRotation; @VerticalRotation.performed += instance.OnVerticalRotation; @VerticalRotation.canceled += instance.OnVerticalRotation; @HorizontalRotation.started += instance.OnHorizontalRotation; @HorizontalRotation.performed += instance.OnHorizontalRotation; @HorizontalRotation.canceled += instance.OnHorizontalRotation; + @MouseRotation.started += instance.OnMouseRotation; + @MouseRotation.performed += instance.OnMouseRotation; + @MouseRotation.canceled += instance.OnMouseRotation; + @SnapRight.started += instance.OnSnapRight; + @SnapRight.performed += instance.OnSnapRight; + @SnapRight.canceled += instance.OnSnapRight; + @SnapLeft.started += instance.OnSnapLeft; + @SnapLeft.performed += instance.OnSnapLeft; + @SnapLeft.canceled += instance.OnSnapLeft; } } } @@ -1235,10 +1363,11 @@ public void SetCallbacks(IInteractionsActions instance) public interface ICameraActions { void OnZoom(InputAction.CallbackContext context); - void OnSnapRight(InputAction.CallbackContext context); - void OnSnapLeft(InputAction.CallbackContext context); void OnVerticalRotation(InputAction.CallbackContext context); void OnHorizontalRotation(InputAction.CallbackContext context); + void OnMouseRotation(InputAction.CallbackContext context); + void OnSnapRight(InputAction.CallbackContext context); + void OnSnapLeft(InputAction.CallbackContext context); } public interface IMovementActions { diff --git a/Assets/Scripts/SS3D/Systems/Inputs/InputSystem.cs b/Assets/Scripts/SS3D/Systems/Inputs/InputSystem.cs index cc8be459c0..314546470a 100644 --- a/Assets/Scripts/SS3D/Systems/Inputs/InputSystem.cs +++ b/Assets/Scripts/SS3D/Systems/Inputs/InputSystem.cs @@ -11,6 +11,7 @@ namespace SS3D.Systems.Inputs public class InputSystem : SS3D.Core.Behaviours.System { public Controls Inputs { get; private set; } + public float MouseSensitivity { get; private set; } private Dictionary _actionDisables; protected override void OnAwake() @@ -18,7 +19,8 @@ protected override void OnAwake() DontDestroyOnLoad(transform.gameObject); base.OnAwake(); - + + MouseSensitivity = 0.001f; Inputs = new Controls(); _actionDisables = new(); foreach (InputAction action in Inputs) diff --git a/Assets/Scripts/SS3D/Systems/Screens/CameraFollow.cs b/Assets/Scripts/SS3D/Systems/Screens/CameraFollow.cs index 69c3baaef1..3cb5f24274 100644 --- a/Assets/Scripts/SS3D/Systems/Screens/CameraFollow.cs +++ b/Assets/Scripts/SS3D/Systems/Screens/CameraFollow.cs @@ -3,6 +3,7 @@ using SS3D.Core.Behaviours; using UnityEngine; using System; +using System.Collections; using SS3D.Core; using SS3D.Systems.Inputs; using UnityEngine.InputSystem; @@ -63,7 +64,7 @@ public class CameraFollow : Actor private Controls.CameraActions _controls; private InputSystem _inputSystem; - + // Sensitivities and Accelerations private const float DistanceAcceleration = 10.0f; private const float AngleAcceleration = 8f; @@ -86,6 +87,7 @@ public class CameraFollow : Actor private const float MinDistance = 3f; private const float MaxDistance = 15f; private const float SnapAngle = 45.1f; + private const float MouseSnapThreshold = 0.04f; #endregion @@ -97,6 +99,7 @@ protected override void OnStart() _controls.Zoom.performed += HandleZoom; _controls.SnapRight.performed += HandleSnapRight; _controls.SnapLeft.performed += HandleSnapLeft; + _controls.MouseRotation.performed += HandleMouseRotation; _inputSystem.ToggleActionMap(_controls, true); AddHandle(UpdateEvent.AddListener(HandleUpdate)); @@ -109,9 +112,10 @@ protected override void OnDestroyed() _controls.Zoom.performed -= HandleZoom; _controls.SnapRight.performed -= HandleSnapRight; _controls.SnapLeft.performed -= HandleSnapLeft; + _controls.MouseRotation.performed -= HandleMouseRotation; _inputSystem.ToggleActionMap(_controls, false); } - + private void HandleUpdate(ref EventContext context, in UpdateEvent updateEvent) { ProcessCameraPosition(); @@ -122,21 +126,42 @@ private void HandleZoom(InputAction.CallbackContext context) _cameraDistance = Mathf.Clamp(_cameraDistance - context.ReadValue(), MinDistance, MaxDistance); } - // There are two button-type actions for snap, because MultiTap actions don't return values when performed + // There are two button-type actions for snap, because Tap actions don't return values when performed private void HandleSnapLeft(InputAction.CallbackContext context) { - Snap(1); + Snap(true); } private void HandleSnapRight(InputAction.CallbackContext context) { - Snap(-1); + Snap(false); } - private void Snap(float direction) + private void Snap(bool isLeft) { + int direction = isLeft? 1 : -1; _horizontalAngle = Mathf.Round((_horizontalAngle + SnapAngle * direction) / 90.0f) * 90.0f; } + private void HandleMouseRotation(InputAction.CallbackContext context) + { + float value = context.ReadValue() * _inputSystem.MouseSensitivity; + if (Math.Abs(value) > MouseSnapThreshold) + { + Snap(value > 0); + _inputSystem.ToggleAction(_controls.MouseRotation, false); + StartCoroutine(MouseRotationTimeout(.4f)); + } + else + { + _horizontalAngle += value * HorizontalRotationSensitivity; + } + } + + private IEnumerator MouseRotationTimeout(float time) + { + yield return new WaitForSeconds(time); + _inputSystem.ToggleAction(_controls.MouseRotation, true); + } /// /// Determine camera position after any physics/player movement diff --git a/Assets/Settings/InputSystem.inputsettings.asset b/Assets/Settings/InputSystem.inputsettings.asset index 170571f6a2..cb9a6d7683 100644 --- a/Assets/Settings/InputSystem.inputsettings.asset +++ b/Assets/Settings/InputSystem.inputsettings.asset @@ -29,7 +29,7 @@ MonoBehaviour: m_TapRadius: 5 m_MultiTapDelayTime: 0.75 m_DisableRedundantEventsMerging: 0 - m_ShortcutKeysConsumeInputs: 0 + m_ShortcutKeysConsumeInputs: 1 m_iOSSettings: m_MotionUsage: m_Enabled: 0