added float axis support and gameplay scene

This commit is contained in:
MrTorex committed 2026-01-30 18:25:35 +03:00
1 parent 12ec4f72f5
commit 158850aa45
8 files changed
+1519 -9

No files matched your search

+13 -6
View File
@@ -10,9 +10,7 @@ namespace Code.Input
public Vector2 MainMenuParalax { get; private set; }
public Vector2 LookInput { get; private set; }
public Vector2 MoveInput { get; private set; }
public bool SwitchCameraPressed { get; private set; }
public float MoveInput { get; private set; }
public InputService(InputActionAsset inputActionAsset)
{
@@ -29,9 +27,7 @@ namespace Code.Input
private void SetupGameplayInputCallbacks()
{
var map = _inputActionAsset.actionMaps[(int)ActionMapping.Gameplay];
BindVector2(map, "Look", v => LookInput = v);
BindVector2(map, "Move", v => MoveInput = v);
BindButton(map, "SwitchCamera", v => SwitchCameraPressed = v);
BindAxis(map, "Move", v => MoveInput = v);
}
private void SetupMainMenuInputCallbacks()
@@ -61,6 +57,17 @@ namespace Code.Input
action.performed += ctx => setter(ctx.ReadValue<Vector2>());
action.canceled += _ => setter(Vector2.zero);
}
private void BindAxis(InputActionMap map, string actionName, System.Action<float> setter)
{
var action = map.FindAction(actionName);
if (action == null)
return;
action.performed += ctx => setter(ctx.ReadValue<float>());
action.canceled += _ => setter(0f);
}
public void EnableMap(ActionMapping actionMap)
{