Proper input layering with console

This commit is contained in:
2025-03-18 01:25:09 +02:00
parent 19cda04372
commit e564cf36a8
6 changed files with 113 additions and 51 deletions

View File

@@ -1,27 +0,0 @@
using FlaxEngine;
namespace Game;
public static class InputManager
{
public static bool GetAction(string name)
{
if (Console.IsOpen)
return false;
return Input.GetAction(name);
}
public static float GetAxis(string name)
{
if (Console.IsOpen)
return 0.0f;
return Input.GetAxis(name);
}
public static float GetAxisRaw(string name)
{
if (Console.IsOpen)
return 0.0f;
return Input.GetAxisRaw(name);
}
}

View File

@@ -51,19 +51,19 @@ public class PlayerInputLocal : PlayerInput
float sensitivity = 1.0f / 8.0f;
sensitivity = 1.0f;
//var asf = InputManager.GetAxisRaw("Mouse X");
//var asf = Input.GetAxisRaw("Mouse X");
//if (asf != 0.0f)
// Console.Print(InputManager.GetAxisRaw("Mouse X").ToString("G9", System.Globalization.CultureInfo.InvariantCulture));
// Console.Print(Input.GetAxisRaw("Mouse X").ToString("G9", System.Globalization.CultureInfo.InvariantCulture));
currentState.input.viewDeltaX += InputManager.GetAxisRaw("Mouse X") * sensitivity;
currentState.input.viewDeltaY += InputManager.GetAxisRaw("Mouse Y") * sensitivity;
currentState.input.viewDeltaX += InputManager.GetAxisRaw("LookRight") * Time.DeltaTime * 100;
currentState.input.viewDeltaY += -InputManager.GetAxisRaw("LookUp") * Time.DeltaTime * 100;
currentState.input.viewDeltaX += Input.GetAxisRaw("Mouse X") * sensitivity;
currentState.input.viewDeltaY += Input.GetAxisRaw("Mouse Y") * sensitivity;
currentState.input.viewDeltaX += Input.GetAxisRaw("LookRight") * Time.DeltaTime * 100;
currentState.input.viewDeltaY += -Input.GetAxisRaw("LookUp") * Time.DeltaTime * 100;
currentState.input.moveForward = InputManager.GetAxis("Vertical");
currentState.input.moveRight = InputManager.GetAxis("Horizontal");
currentState.input.attacking = InputManager.GetAction("Attack");
currentState.input.jumping = InputManager.GetAction("Jump");
currentState.input.moveForward = Input.GetAxis("Vertical");
currentState.input.moveRight = Input.GetAxis("Horizontal");
currentState.input.attacking = Input.GetAction("Attack");
currentState.input.jumping = Input.GetAction("Jump");
}