축제 잔디 사망루트
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Locomotion;
|
||||
using UnityEngine.InputSystem.XR;
|
||||
|
||||
public class PlayerController : MonoBehaviour
|
||||
{
|
||||
// 시야 가림용 구체(Sight)가 쓰는 머티리얼 — 알파 0(투명)이면 정상 시야, 1(불투명)이면 암전
|
||||
[SerializeField] private Material _sightMat;
|
||||
|
||||
[SerializeField] private GameObject _bloodDieImgRef;
|
||||
[SerializeField] private AudioClip _bloodSfx;
|
||||
|
||||
private static readonly int _baseColorId = Shader.PropertyToID("_BaseColor");
|
||||
private static readonly int _colorId = Shader.PropertyToID("_Color");
|
||||
|
||||
@@ -46,4 +51,39 @@ private void SetSightAlpha(float alpha)
|
||||
color.a = alpha;
|
||||
_sightMat.SetColor(AlphaProp, color);
|
||||
}
|
||||
|
||||
public void PlayerBloodDie(float duration)
|
||||
{
|
||||
_ = Util.RunDelayed(duration, () =>
|
||||
{
|
||||
StopPlayerMovement(); // XR 이동/회전 정지 — PauseAllAnimations로는 못 막는다
|
||||
LocalManager.PauseAllAnimations();
|
||||
_bloodDieImgRef.SetActive(true);
|
||||
SoundManager.Instance.PlaySFX(_bloodSfx);
|
||||
},this.destroyCancellationToken);
|
||||
|
||||
}
|
||||
|
||||
// Player 태그 루트(XR Origin) 아래에서 플레이어가 시야/위치를 바꾸는 수단을 전부 정지시킨다:
|
||||
// 1) LocomotionProvider → 이동/회전(중력 포함)
|
||||
// 2) TrackedPoseDriver → 헤드셋·컨트롤러 트래킹. 카메라 드라이버를 꺼야 머리를 돌려도 시야가 안 돈다
|
||||
// PauseAllAnimations는 Animator/타임라인/파티클만 멈추므로 이 둘은 못 막는다. 사망 연출이라 복구하지 않는다.
|
||||
private static void StopPlayerMovement()
|
||||
{
|
||||
var playerRoot = GameObject.FindWithTag("Player");
|
||||
if (playerRoot == null)
|
||||
{
|
||||
Debug.LogWarning("[PlayerController] 'Player' 태그 루트를 찾지 못해 이동 정지를 건너뜁니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
// 이동/회전(로코모션)
|
||||
foreach (var provider in playerRoot.GetComponentsInChildren<LocomotionProvider>(true))
|
||||
provider.enabled = false;
|
||||
|
||||
// 헤드셋/컨트롤러 트래킹 — 실제 포즈를 매 프레임 카메라/손에 적용하는 드라이버를 꺼 시야를 고정.
|
||||
// (컨트롤러 손도 함께 멈춘다. 카메라만 얼리려면 Camera.main의 드라이버만 끄면 됨)
|
||||
foreach (var driver in playerRoot.GetComponentsInChildren<TrackedPoseDriver>(true))
|
||||
driver.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user