2026-03-17 시네머신 카메라 묶음 수정. 여러 카메라릭에서 공유하도록 공통 시네머신카메라리스트 분리
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Unity.Cinemachine;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using static Unity.Cinemachine.CinemachineSplineDolly;
|
||||
|
||||
public class PlayerCharacterController : MonoBehaviour
|
||||
{
|
||||
@@ -45,7 +48,11 @@ public class PlayerCharacterController : MonoBehaviour
|
||||
private CameraMode _cameraMode = CameraMode.FreeLook; //카메라 모드
|
||||
private CancellationTokenSource _cameraDelayChangeCts; //지연전환 취소 토큰
|
||||
public enum PlayerRotationMode {CameraCoupled, CameraDecoupled}
|
||||
public PlayerRotationMode RotationMode;
|
||||
public PlayerRotationMode RotationMode = PlayerRotationMode.CameraCoupled;
|
||||
|
||||
//일단은 기본값
|
||||
public bool Strafe = false;
|
||||
public void SetStrafeMode(bool b) => Strafe = b;
|
||||
|
||||
|
||||
//캐릭터 관련
|
||||
@@ -255,8 +262,8 @@ private void Movement()
|
||||
|
||||
Debug.Log($"Forward : {camForward}");
|
||||
|
||||
//카메라가 보는 방향으로 회전
|
||||
RotationByVector(camForward);
|
||||
//모드별 회전
|
||||
RotationByMode();
|
||||
_anim.SetFloat("DirectX", moveDir.x * _currentSpd / _spdCoefficient);
|
||||
_anim.SetFloat("DirectY", moveDir.z * _currentSpd / _spdCoefficient);
|
||||
|
||||
@@ -269,10 +276,38 @@ private void RotationByMove()
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, lookTarget, Time.deltaTime * 10);
|
||||
}
|
||||
}
|
||||
private void RotationByVector(Vector3 dir)
|
||||
private void RotationByMode()
|
||||
{
|
||||
transform.forward = Vector3.Slerp(transform.forward, dir, Time.deltaTime * 10);
|
||||
switch (RotationMode)
|
||||
{
|
||||
case PlayerRotationMode.CameraCoupled:
|
||||
{
|
||||
SetStrafeMode(true);
|
||||
RecenterPlayer();
|
||||
break;
|
||||
}
|
||||
case PlayerRotationMode.CameraDecoupled:
|
||||
{
|
||||
SetStrafeMode(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RecenterPlayer(float damping = 0)
|
||||
{
|
||||
if (transform == null)
|
||||
return;
|
||||
|
||||
Vector3 cameraForward = Camera.main.transform.forward;
|
||||
cameraForward.y = 0;
|
||||
cameraForward.Normalize();
|
||||
|
||||
Quaternion targetRotation = Quaternion.LookRotation(cameraForward);
|
||||
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation,targetRotation,damping > 0 ? Time.deltaTime / damping : 1f );
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 속도적용
|
||||
@@ -310,14 +345,6 @@ private void JumpAction()
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 카메라
|
||||
public void RecenterPlayer()
|
||||
{
|
||||
if(GameManager.Instance.Camera != null)
|
||||
GameManager.Instance.Camera.RecenterPlayer();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 타미어
|
||||
private void TickTimer()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user