Erste Soundeffekte

This commit is contained in:
DominikB
2023-06-24 13:49:28 +02:00
parent da69707106
commit 63e74b9229
12 changed files with 708 additions and 517 deletions

View File

@@ -8,10 +8,13 @@ public GameObject door;
public SpriteRenderer spriteRenderer;
public Sprite originalSprite;
public Sprite activatedSprite;
public AudioSource audioSource; // Reference to the AudioSource component
public AudioClip buttonClickSound; // The sound clip to be played
private bool isActive = false;
// Start is called before the first frame update
void Start()
{
audioSource = GetComponent<AudioSource>();
}
// Update is called once per frame
@@ -24,6 +27,10 @@ void OnTriggerEnter2D(Collider2D other) {
if (other.CompareTag("PressurePlatable")){
door.SetActive(false);
spriteRenderer.sprite = activatedSprite;
if(!isActive){
audioSource.PlayOneShot(buttonClickSound);
isActive = true;
}
}
}