working on fpp locomotion, camera spring
This commit is contained in:
@@ -5,7 +5,7 @@ using RebootKit.Engine;
|
||||
using RebootKit.Engine.Foundation;
|
||||
using RebootKit.Engine.Main;
|
||||
using RebootKit.Engine.Services.Input;
|
||||
using RebootKit.FPPKit;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.InputSystem;
|
||||
@@ -57,6 +57,8 @@ namespace RealityReboot.jelycho.Player {
|
||||
Vector2 moveInput = m_Config.moveActionReference.action.ReadValue<Vector2>();
|
||||
m_FPPActor.SetMoveInput(moveInput);
|
||||
|
||||
m_FPPActor.SetSprint(m_Config.sprintActionReference.action.IsPressed());
|
||||
|
||||
if (m_Config.jumpActionReference.action.WasPerformedThisFrame()) {
|
||||
m_FPPActor.Jump();
|
||||
}
|
||||
@@ -77,9 +79,40 @@ namespace RealityReboot.jelycho.Player {
|
||||
public InputActionReference moveActionReference;
|
||||
public InputActionReference lookActionReference;
|
||||
public InputActionReference jumpActionReference;
|
||||
public InputActionReference sprintActionReference;
|
||||
public InputActionReference dragObjectActionReference;
|
||||
public InputActionReference primaryActionReference;
|
||||
public InputActionReference secondaryActionReference;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FPPConfig {
|
||||
[ConfigVar("fpp.mouse.sens", 0.25f, "Mouse look sensitivity")] public static ConfigVar s_MouseSensitivity;
|
||||
[ConfigVar("fpp.mouse.invert.y", 0, "Invert mouse look")] public static ConfigVar s_MouseInvertY;
|
||||
[ConfigVar("fpp.gamepad.sens", 4.0f, "Gamepad look sensitivity")] public static ConfigVar s_GamepadSensitivity;
|
||||
}
|
||||
|
||||
public static class SensitivityReader {
|
||||
public static float2 Read(InputAction action) {
|
||||
if (action == null || action.activeControl == null) {
|
||||
return float2.zero;
|
||||
}
|
||||
|
||||
float2 sensitivity = action.ReadValue<Vector2>();
|
||||
|
||||
bool isGamepad = action.activeControl.device is Gamepad;
|
||||
|
||||
if (isGamepad) {
|
||||
sensitivity *= FPPConfig.s_GamepadSensitivity.FloatValue;
|
||||
} else {
|
||||
sensitivity *= FPPConfig.s_MouseSensitivity.FloatValue;
|
||||
|
||||
if (FPPConfig.s_MouseInvertY.IndexValue == 1) {
|
||||
sensitivity.y *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
return sensitivity;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user