Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. //using UnityEngine;
  6. //using System.Collections;
  7. [RequireComponent(typeof(AudioSource))]
  8. public class collision : MonoBehaviour
  9. {
  10.  
  11. void start()
  12. {
  13.  
  14. }
  15.  
  16. void Update()
  17. {
  18.  
  19. }
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. void OnCollisionEnter(Collision collisionInfo)
  28. {
  29.  
  30. if (collisionInfo.gameObject.name != "Plane" && collisionInfo.gameObject.name == "Keys")
  31. gameObject.GetComponent<Renderer>().material.color = Color.red;
  32. AudioSource audio = GetComponent<AudioSource>();
  33. if (!audio.isPlaying)
  34. {
  35.  
  36. audio.Play();
  37.  
  38. }
  39. //while(audio.isPlaying)
  40. //{
  41. // if(collisionInfo.gameObject.name == "HandModels")
  42. // audio.Play();
  43. //}
  44. for(int i=0; i<3; i++)
  45. {
  46. string s = "Box" + i;
  47. if(collisionInfo.gameObject)
  48. }
  49. }
  50.  
  51. void OnCollisionStay(Collision collisionInfo)
  52. {
  53. if (collisionInfo.gameObject.name != "Plane" )
  54. gameObject.GetComponent<Renderer>().material.color = Color.red;
  55.  
  56. }
  57.  
  58. void OnCollisionExit(Collision collisionInfo)
  59. {
  60. if (collisionInfo.gameObject.name != "Plane" || collisionInfo.gameObject.name != "Keys")
  61. gameObject.GetComponent<Renderer>().material.color = Color.white;
  62. AudioSource audio = GetComponent<AudioSource>();
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement