- Home /
Question by
Alcal3 · Dec 23, 2013 at 08:12 AM ·
backgroundmusicstoppower-up
Stop Background Music for PowerUp Music
I want to be able to stop my current background music whenever I grab a power up and play the power up music, with no luck so far
using UnityEngine;
using System.Collections;
public class Move : MonoBehaviour {
public AudioClip guile;
public AudioClip rule;
// Use this for initialization
void Start () {
AudioSource.PlayClipAtPoint (rule, transform.position);
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D (Collider2D col){
if (col.gameObject.tag == "PowerUp") {
AudioSource.Stop();
AudioSource.PlayClipAtPoint(guile,transform.position);
Destroy(col.gameObject);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Stop continuing music (Please Help) 1 Answer
Change (Background) Music Mid-Game 2 Answers
How to deactivate background music when I land on an object? 1 Answer
Don't destroy a variable when changing scene 2 Answers
Background Music 3 Answers