Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CollisionBoom : MonoBehaviour {
  6. public Renderer rend;
  7.  
  8. // Use this for initialization
  9. void Start () {
  10. rend = GetComponent<Renderer>();
  11. }
  12.  
  13. // Update is called once per frame
  14. void Update () {
  15.  
  16. }
  17.  
  18. //OnCollisionEnter runs every time there is a collision of this object
  19. //The Collision class describes the collision, which is why we called it a colReport
  20. void OnCollisionEnter(Collision colReport){
  21. //only do something if the collision report says the object collided with was a...
  22. //game object with a tag property of "duckling"
  23. if (colReport.gameObject.tag == "duckling"){
  24. //if so, tell the console
  25. Debug.Log("hit occurred");
  26. //change the color of this object to blue
  27. rend.material.color = Color.blue;
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement