Reputation: 21
So I'm making a Ball game where the goal is to dodge obstacles and reach the end of the level.
I've made a wind effect sound for when the player reaches a certain amount of speed.. however, when the player hits an obstacle and dies, the sound of the wind continues.
My question is: How do I turn off a specific Audio when my player dies? I'm not quite sure what functions & stuff I should put in my code.
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObstacleCollisionBig : MonoBehaviour
{
public GameObject destroyedObstacle;
void OnCollisionEnter(Collision collisionInfo)
{
if (collisionInfo.collider.tag == "Player")
{
Instantiate(destroyedObstacle, transform.position, transform.rotation);
FindObjectOfType<AudioManager>().Play("ShatterBig");
Destroy(gameObject);
}
}
}
If I wasn't clear enough, feel free to ask about more information.
Thanks in advance, E.W
Upvotes: 2
Views: 408