This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using DefaultNamespace;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Input
|
||||
{
|
||||
public class PlayerCameraInputHandler : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private PlayerCameraController cameraController;
|
||||
[SerializeField] [Range(0, 100)] private float rotationSensitivity;
|
||||
[SerializeField] [Range(0, 1)] private float zoomSensitivity;
|
||||
|
||||
private bool _allowRotation;
|
||||
|
||||
public void OnInputZoom(InputAction.CallbackContext context)
|
||||
{
|
||||
var input = context.ReadValue<float>();
|
||||
var zoomAmount = input * zoomSensitivity * Time.deltaTime;
|
||||
cameraController.Zoom(zoomAmount);
|
||||
}
|
||||
|
||||
public void OnInputRotate(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.phase != InputActionPhase.Performed) return;
|
||||
if (!_allowRotation) return;
|
||||
|
||||
var input = context.ReadValue<float>();
|
||||
var rotationAmount = input * rotationSensitivity * Time.deltaTime;
|
||||
cameraController.RotateAround(rotationAmount);
|
||||
}
|
||||
|
||||
public void OnInputHoldToRotate(InputAction.CallbackContext context)
|
||||
{
|
||||
_allowRotation = context.phase switch
|
||||
{
|
||||
InputActionPhase.Performed => true,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b94be55d5ec4fedb531d50297528d3b
|
||||
timeCreated: 1690824962
|
||||
Reference in New Issue
Block a user