feat: improve VR menu pointer and BeatSaber flow

This commit is contained in:
jongjae0305
2026-05-26 17:13:02 +09:00
parent 58838f0acb
commit 10e9ebae45
20 changed files with 637 additions and 58 deletions
@@ -20,6 +20,11 @@ namespace VRBeats
public override void DoDamage(DamageInfo info)
{
// 방향·속도·색상이 맞지 않으면 자르지 않음
var beatCube = GetComponent<VR_BeatCube>();
if (beatCube != null && !beatCube.IsCutIntentValid(info as BeatDamageInfo))
return;
onCut.Invoke(info);
var beatDamageInfo = info as BeatDamageInfo;
@@ -7,6 +7,7 @@ namespace VRBeats
public class VR_BeatCube : MonoBehaviour
{
[SerializeField] private float minCutSpeed = 0.5f;
[SerializeField] private float maxCutAngle = 40f;
[SerializeField] private OnSliceAction sliceAction = null;
[SerializeField] private GameEvent onCorrectSlice = null;
[SerializeField] private GameEvent onIncorrectSlice = null;
@@ -65,7 +66,7 @@ namespace VRBeats
}
private bool IsCutIntentValid(BeatDamageInfo info)
public bool IsCutIntentValid(BeatDamageInfo info)
{
if (info == null) return false;
@@ -76,7 +77,7 @@ namespace VRBeats
return true;
float cutAngle = Vector2.Angle(transform.up, info.hitDir);
return info.colorSide == ThisColorSide && cutAngle < 80.0f;
return info.colorSide == ThisColorSide && cutAngle < maxCutAngle;
}
@@ -5,18 +5,20 @@ namespace VRBeats
{
public class VR_InteractorController : MonoBehaviour
{
[SerializeField] private bool disableOnAwake = true;
private UnityEngine.XR.Interaction.Toolkit.Interactors.XRRayInteractor rayInteractor = null;
private UnityEngine.XR.Interaction.Toolkit.Interactors.Visuals.XRInteractorLineVisual interactorLineVisual = null;
private LineRenderer lineRender = null;
private void Awake()
{
rayInteractor = GetComponent<UnityEngine.XR.Interaction.Toolkit.Interactors.XRRayInteractor>();
interactorLineVisual = GetComponent<UnityEngine.XR.Interaction.Toolkit.Interactors.Visuals.XRInteractorLineVisual>();
lineRender = GetComponent<LineRenderer>();
DisableXRRayInteractorComponents();
if (disableOnAwake)
DisableXRRayInteractorComponents();
}
public void DisableXRRayInteractorComponents()
@@ -24,13 +26,20 @@ namespace VRBeats
rayInteractor.enabled = false;
interactorLineVisual.enabled = false;
lineRender.enabled = false;
// VRPointerController는 부모("LeftHand/RightHand Controller")에 추가되므로 InParent로 탐색
var pointer = GetComponentInParent<VRPointerController>();
if (pointer != null) pointer.enabled = false;
}
public void EnableXRRayInteractorComponents()
{
{
rayInteractor.enabled = true;
interactorLineVisual.enabled = true;
lineRender.enabled = true;
var pointer = GetComponentInParent<VRPointerController>();
if (pointer != null) pointer.enabled = true;
}
}