feat():为压力板、按钮、拉杆添加音效,为玩家移动添加音效
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user