2026-04-29 음식섭취 - 포만감 연동
This commit is contained in:
Binary file not shown.
@@ -19,13 +19,11 @@ public class TastingSample : MonoBehaviour
|
|||||||
[SerializeField] private bool _requireGrabbed = true;
|
[SerializeField] private bool _requireGrabbed = true;
|
||||||
|
|
||||||
private XRGrabInteractable _grab;
|
private XRGrabInteractable _grab;
|
||||||
private AudioSource _sfxSource;
|
|
||||||
private bool _consumed;
|
private bool _consumed;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_grab = GetComponent<XRGrabInteractable>();
|
_grab = GetComponent<XRGrabInteractable>();
|
||||||
_sfxSource = GetComponent<AudioSource>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
@@ -42,19 +40,32 @@ private void Update()
|
|||||||
|
|
||||||
private void Consume()
|
private void Consume()
|
||||||
{
|
{
|
||||||
|
var interactor = _grab.firstInteractorSelecting as MonoBehaviour;
|
||||||
|
|
||||||
_consumed = true;
|
_consumed = true;
|
||||||
|
|
||||||
// 손에서 강제 해제 (잡혀있던 상태로 Destroy되면 XRI 경고)
|
// 손에서 강제 해제 (잡혀있던 상태로 Destroy되면 XRI 경고)
|
||||||
if (_grab != null && _grab.isSelected && _grab.interactionManager != null)
|
if (_grab != null && _grab.isSelected && _grab.interactionManager != null)
|
||||||
_grab.interactionManager.CancelInteractableSelection((UnityEngine.XR.Interaction.Toolkit.Interactables.IXRSelectInteractable)_grab);
|
_grab.interactionManager.CancelInteractableSelection((UnityEngine.XR.Interaction.Toolkit.Interactables.IXRSelectInteractable)_grab);
|
||||||
|
|
||||||
// SFX 재생 후 파괴 (사운드 길이 고려)
|
PlayerHunger hunger = interactor != null ? interactor.GetComponentInParent<PlayerHunger>() : null;
|
||||||
var sfx = _foodData.EatSfx;
|
if(hunger != null)
|
||||||
if (sfx != 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);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -123,7 +123,8 @@ AudioMixerSnapshotController:
|
|||||||
m_Name: Snapshot
|
m_Name: Snapshot
|
||||||
m_AudioMixer: {fileID: 24100000}
|
m_AudioMixer: {fileID: 24100000}
|
||||||
m_SnapshotID: 57a15260ec480004cbc2848cc0a4f36e
|
m_SnapshotID: 57a15260ec480004cbc2848cc0a4f36e
|
||||||
m_FloatValues: {}
|
m_FloatValues:
|
||||||
|
ba018e28170e108488d70eb228687256: 10
|
||||||
m_TransitionOverrides: {}
|
m_TransitionOverrides: {}
|
||||||
--- !u!244 &2045488911297964458
|
--- !u!244 &2045488911297964458
|
||||||
AudioMixerEffectController:
|
AudioMixerEffectController:
|
||||||
|
|||||||
Binary file not shown.
BIN
Assets/10_Audio/SFX/SFX_EatingFood.wav
LFS
Normal file
BIN
Assets/10_Audio/SFX/SFX_EatingFood.wav
LFS
Normal file
Binary file not shown.
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 17dbbd3089b458c4ebe08efe4be987e8
|
guid: f782565ec8f93fb4f881223891b638de
|
||||||
AudioImporter:
|
AudioImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 8
|
serializedVersion: 8
|
||||||
Reference in New Issue
Block a user