Created
April 9, 2020 16:07
-
-
Save smkplus/5c30286d7fbb5c05bc0d717586b35464 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class AudioComponent : MonoBehaviour | |
{ | |
//Audio Clips | |
[SerializeField] private AudioClip attackSfx; | |
[SerializeField] private AudioClip playerDeathSfx; | |
//Audio Sources | |
[SerializeField] private AudioSource audioSource; | |
public void PlayAttackSfx() | |
{ | |
if (audioSource != null && attackSfx != null) | |
{ | |
audioSource.clip = attackSfx; | |
audioSource.Play(); | |
} | |
} | |
public void PlayPlayerDeathSfx() | |
{ | |
if (audioSource != null && playerDeathSfx != null) | |
{ | |
audioSource.clip = playerDeathSfx; | |
audioSource.Play(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment