Advertisement
Guest User

Untitled

a guest
Apr 12th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using AC;
  4.  
  5. public class VoiceSound1 : MonoBehaviour {
  6. public AudioClip myAudioClip;
  7. public AudioClip myAudioClip2;
  8.  
  9. // Use this for initialization
  10. void GetSpeech (AC.Char speakingCharacter, string speechText, int lineID)
  11. {
  12.  
  13. if (speakingCharacter != null && speakingCharacter.gameObject.name == "Test 1" || speakingCharacter.gameObject.name == "Test 2")
  14. {
  15. float randValue = Random.value;
  16. if (randValue < .30f)
  17. {
  18. AudioSource.PlayClipAtPoint (myAudioClip, AC.KickStarter.mainCamera.transform.position);
  19. }
  20. else if (randValue < .70f)
  21. {
  22. AudioSource.PlayClipAtPoint (myAudioClip2, AC.KickStarter.mainCamera.transform.position);
  23. }
  24. }
  25.  
  26. }
  27. private void OnEnable()
  28. {
  29.  
  30. EventManager.OnStartSpeech +=GetSpeech;
  31. }
  32.  
  33. private void OnDisable()
  34. {
  35. EventManager.OnStartSpeech -=GetSpeech;
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement