Add jump sounds

This commit is contained in:
haitem
2022-01-30 11:42:15 +01:00
parent 337f009d77
commit e5a83b0434
13 changed files with 129 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ public class PlayerController : MonoBehaviour
public ParticleSystem runningParticles;
public Transform mainObject;
public AudioSource audioSource;
public List<AudioClip> jumpClips = new List<AudioClip>();
public List<AudioClip> audioClips = new List<AudioClip>();
// Start is called before the first frame update
@@ -138,6 +139,10 @@ public class PlayerController : MonoBehaviour
if (inAir)
{
// Debug.Log("Jump");
if (audioSource != null && jumpClips.Count > 0)
{
audioSource.PlayOneShot(jumpClips[Random.Range(0, jumpClips.Count)]);
}
rb.AddForce(transform.up * jumpSpeed * 100f * Time.deltaTime, ForceMode.Impulse);
inAir = false;
}