feat():为压力板、按钮、拉杆添加音效,为玩家移动添加音效

This commit is contained in:
2025-10-29 17:05:10 +08:00
parent 97a3a351d7
commit 3c438b3871
11 changed files with 512 additions and 4 deletions

View File

@@ -11,6 +11,10 @@ namespace Script.Gameplay.Facility
[SerializeField] private Vector3 plateOffset = Vector3.up * 0.1f;
[SerializeField] private GameObject pressTopPrefab;
[SerializeField] private AudioClip pressedSound;
[SerializeField] private AudioClip returnSound;
[SerializeField] private AudioSource plateSound;
private bool lastState = false;
private bool hasObject = false;
@@ -27,13 +31,21 @@ namespace Script.Gameplay.Facility
{
// 被压下动画
if (pressTopPrefab != null)
{
pressTopPrefab.transform.localPosition = new Vector3(0, 0, 0.1f);
plateSound.clip = pressedSound;
plateSound.Play();
}
}
else
{
// 弹起动画
if (pressTopPrefab != null)
{
pressTopPrefab.transform.localPosition = new Vector3(0, 0, 1);
plateSound.clip = returnSound;
plateSound.Play();
}
}
}
}