2026-03-17 14:19 FPS시점의 Strafe캐릭터 조작과 에임모드 전환
This commit is contained in:
@@ -11,6 +11,10 @@ public class GameManager : MonoBehaviour
|
||||
public LevelManager Level { get; private set; }
|
||||
public CameraManager Camera { get; private set; }
|
||||
|
||||
//UI
|
||||
public IntroUIManager IntroUI { get; private set; }
|
||||
public InGameUIManager InGameUI { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
@@ -29,15 +33,16 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
// 씬이 로드될 때마다 해당 씬에 있는 Manager들을 찾아서 갱신
|
||||
// 없으면 자동으로 null이 들어감
|
||||
Level = FindFirstObjectByType<LevelManager>();
|
||||
Camera = FindFirstObjectByType<CameraManager>();
|
||||
|
||||
if(Level != null) Level.OnSceneLoaded(scene, mode);
|
||||
if(Camera != null) Camera.OnSceneLoaded(scene, mode);
|
||||
this.Level = FindFirstObjectByType<LevelManager>();
|
||||
this.Camera = FindFirstObjectByType<CameraManager>();
|
||||
this.IntroUI = FindFirstObjectByType<IntroUIManager>();
|
||||
this.InGameUI = FindFirstObjectByType<InGameUIManager>();
|
||||
|
||||
if (this.Level != null) this.Level.OnSceneLoaded(scene, mode);
|
||||
if (this.Camera != null) this.Camera.OnSceneLoaded(scene, mode);
|
||||
|
||||
InputManager.Instance.PlayerInputEnable(true);
|
||||
GlobalUIManager.Instance.SetSceneLoadingActive(false);
|
||||
|
||||
}
|
||||
|
||||
public void RequestSceneChange(string sceneName)
|
||||
|
||||
@@ -20,9 +20,12 @@ public class InputManager : MonoBehaviour
|
||||
public event Action<Vector2> OnMoveEvent;
|
||||
public event Action<InputState> OnSprintEvent;
|
||||
public event Action<InputState> OnJumpEvent;
|
||||
public event Action<InputState> OnAimToggleEvent;
|
||||
public event Action<Vector2> OnLookEvent;
|
||||
public event Action OnNormalAttackEvent;
|
||||
public event Action OnHeavyAttackEvent;
|
||||
|
||||
|
||||
//키조작
|
||||
public event Action OnKeyDown_UpArrowEvent;
|
||||
public event Action OnKeyDown_DownArrowEvent;
|
||||
@@ -95,8 +98,11 @@ public void SetCharacterInputMap(string mapName)
|
||||
BindActionCharacter("Move", OnMove);
|
||||
BindActionCharacter("Sprint", OnSprint);
|
||||
BindActionCharacter("Jump", OnJump);
|
||||
BindActionCharacter("AimToggle", OnAimToggle);
|
||||
BindActionCharacter("Look", OnLook);
|
||||
BindActionCharacter("NormalAttack", OnNormalAttack);
|
||||
BindActionCharacter("HeavyAttack", OnHeavyAttack);
|
||||
|
||||
}
|
||||
|
||||
//매핑용 함수
|
||||
@@ -171,7 +177,18 @@ private void OnJump(InputAction.CallbackContext ctx)
|
||||
OnJumpEvent?.Invoke(InputState.Canceled);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAimToggle(InputAction.CallbackContext ctx)
|
||||
{
|
||||
if (ctx.started)
|
||||
{
|
||||
OnAimToggleEvent?.Invoke(InputState.Started);
|
||||
}
|
||||
}
|
||||
private void OnLook(InputAction.CallbackContext ctx)
|
||||
{
|
||||
Vector2 look = ctx.ReadValue<Vector2>();
|
||||
OnLookEvent?.Invoke(look);
|
||||
}
|
||||
private void OnNormalAttack(InputAction.CallbackContext ctx)
|
||||
{
|
||||
OnNormalAttackEvent?.Invoke();
|
||||
@@ -193,7 +210,7 @@ private void OnKeyDown_UpArrow(InputAction.CallbackContext ctx)
|
||||
private void OnKeyDown_DownArrow(InputAction.CallbackContext ctx)
|
||||
{
|
||||
if (ctx.started)
|
||||
OnKeyDown_UpArrowEvent?.Invoke();
|
||||
OnKeyDown_DownArrowEvent?.Invoke();
|
||||
}
|
||||
|
||||
private void OnKeyDown_Enter(InputAction.CallbackContext ctx)
|
||||
|
||||
@@ -35,9 +35,10 @@ private async Awaitable InitializeCameraRig()
|
||||
await Awaitable.NextFrameAsync();
|
||||
}
|
||||
|
||||
if (brain.ActiveVirtualCamera is CinemachineCamera cam)
|
||||
// 가져오는게 실제 cinemachine카메라가 아니라 매니저일수도 있기에 MonoBehaviour로 변환후 찾기
|
||||
if (brain.ActiveVirtualCamera is MonoBehaviour activeComponent)
|
||||
{
|
||||
_currentCameraRig = cam.GetComponentInParent<CameraRigBase>();
|
||||
_currentCameraRig = activeComponent.GetComponentInParent<CameraRigBase>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,11 +47,16 @@ public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
|
||||
}
|
||||
|
||||
public void SetCameraRig(AimCameraRig cameraRig)
|
||||
public void SetCameraRig(CameraRigBase cameraRig)
|
||||
{
|
||||
_currentCameraRig = cameraRig;
|
||||
}
|
||||
|
||||
public CinemachineCamera GetLiveCinemachineCamera()
|
||||
{
|
||||
return _currentCameraRig.LiveCmCamera;
|
||||
}
|
||||
|
||||
public void ZoomCamera(float offset)
|
||||
{
|
||||
if (_currentCameraRig is AimCameraRig rig)
|
||||
|
||||
@@ -17,7 +17,7 @@ public class LevelManager : MonoBehaviour
|
||||
[SerializeField] private GameObject[] _playableCharacterPrefabs; //플레이어가 될수 있는 캐릭터들 프리팹 할당
|
||||
public GameObject[] PlayableCharacterPrefabs { get { return _playableCharacterPrefabs; } private set { _playableCharacterPrefabs = value; } }
|
||||
public GameObject CurrentCharacter { get; private set; } // 현재 캐릭터
|
||||
public PlayerCharacterController CurrentCharacterController { get { return CurrentCharacter?.GetComponent<PlayerCharacterController>(); } } // 현재 캐릭터의 컨트롤러
|
||||
public PlayerCharacterController CurrentCharacterController { get { return CurrentCharacter == null ? null : CurrentCharacter.GetComponent<PlayerCharacterController>(); } } // 현재 캐릭터의 컨트롤러
|
||||
public int CurrentCharacterIdx { get; private set; } //현재캐릭터 인덱스
|
||||
#endregion
|
||||
|
||||
@@ -102,6 +102,8 @@ public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
InputManager.Instance.OnMoveEvent += CurrentCharacterController.MoveInput;
|
||||
InputManager.Instance.OnSprintEvent += CurrentCharacterController.SprintInput;
|
||||
InputManager.Instance.OnJumpEvent += CurrentCharacterController.JumpInput;
|
||||
InputManager.Instance.OnAimToggleEvent += CurrentCharacterController.AimToggleInput;
|
||||
InputManager.Instance.OnLookEvent += CurrentCharacterController.LookInput;
|
||||
//InputManager.Instance.OnNormalAttackEvent;
|
||||
//InputManager.Instance.OnHeavyAttackEvent;
|
||||
|
||||
|
||||
@@ -2,15 +2,10 @@
|
||||
|
||||
public class InGameUIManager : BaseUIManager
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
[SerializeField] private GameObject _crosshairRoot;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
public void VisibleCrossHair(bool isOn)
|
||||
{
|
||||
|
||||
_crosshairRoot.SetActive(isOn);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user