Zeether

Jumping audio script

Jan 27th, 2014
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class NewBehaviourScript : MonoBehaviour {
  5.     public AudioClip jump_clip; // defining the audio clip being used
  6.  
  7.     void Start () {
  8.         audio.clip = jump_clip;
  9.     }
  10.    
  11.     // Update is called once per frame
  12.     void Update () {
  13.         if (Input.GetButtonDown("Jump"))
  14.         {
  15.             if(audio.isPlaying == true)
  16.             {
  17.                 audio.Stop();
  18.             }
  19.             else
  20.             {
  21.                 audio.Play();
  22.             }
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment