Advertisement
Guest User

Audio

a guest
Apr 26th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. [RequireComponent(typeof(AudioSource))]
  5. public class CollisionSFX : MonoBehaviour
  6. {
  7.     public AudioClip impact;
  8.     AudioSource audio;
  9.  
  10.     void Start()
  11.     {
  12.         audio = GetComponent<AudioSource>();
  13.     }
  14.  
  15.     void OnCollisionEnter()
  16.     {
  17.         audio.PlayOneShot(impact, 0.7F);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement