2026-04-29 음식섭취 - 포만감 연동

This commit is contained in:
2026-04-29 15:55:42 +09:00
parent 84e5d413c2
commit b626a1b5e6
12 changed files with 34 additions and 22 deletions

Binary file not shown.

View File

@@ -19,13 +19,11 @@ public class TastingSample : MonoBehaviour
[SerializeField] private bool _requireGrabbed = true;
private XRGrabInteractable _grab;
private AudioSource _sfxSource;
private bool _consumed;
private void Awake()
{
_grab = GetComponent<XRGrabInteractable>();
_sfxSource = GetComponent<AudioSource>();
}
private void Update()
@@ -42,19 +40,32 @@ private void Update()
private void Consume()
{
var interactor = _grab.firstInteractorSelecting as MonoBehaviour;
_consumed = true;
// 손에서 강제 해제 (잡혀있던 상태로 Destroy되면 XRI 경고)
if (_grab != null && _grab.isSelected && _grab.interactionManager != null)
_grab.interactionManager.CancelInteractableSelection((UnityEngine.XR.Interaction.Toolkit.Interactables.IXRSelectInteractable)_grab);
// SFX 재생 후 파괴 (사운드 길이 고려)
var sfx = _foodData.EatSfx;
if (sfx != null)
PlayerHunger hunger = interactor != null ? interactor.GetComponentInParent<PlayerHunger>() : null;
if(hunger != null)
{
AudioSource.PlayClipAtPoint(sfx, transform.position);
hunger.Eat(_foodData.HungerRestoreAmount);
}
// VFX/SFX는 임시 오브젝트로 분리 재생 — 본체가 즉시 Destroy되어도 끊기지 않음
if (_foodData.EatVfx != null)
{
var vfx = Instantiate(_foodData.EatVfx, transform.position, Quaternion.identity);
vfx.Play();
var main = vfx.main;
Destroy(vfx.gameObject, main.duration + main.startLifetime.constantMax);
}
if (_foodData.EatSfx != null)
AudioSource.PlayClipAtPoint(_foodData.EatSfx, transform.position);
Destroy(gameObject);
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -123,7 +123,8 @@ AudioMixerSnapshotController:
m_Name: Snapshot
m_AudioMixer: {fileID: 24100000}
m_SnapshotID: 57a15260ec480004cbc2848cc0a4f36e
m_FloatValues: {}
m_FloatValues:
ba018e28170e108488d70eb228687256: 10
m_TransitionOverrides: {}
--- !u!244 &2045488911297964458
AudioMixerEffectController:

Binary file not shown.

Binary file not shown.

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 17dbbd3089b458c4ebe08efe4be987e8
guid: f782565ec8f93fb4f881223891b638de
AudioImporter:
externalObjects: {}
serializedVersion: 8