Advertisement
Guest User

Untitled

a guest
Sep 24th, 2015
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class testcollision : MonoBehaviour {
  5. bool check = false;
  6. bool draw = false;
  7. Collision hitMy;
  8. // Use this for initialization
  9. void Start () {
  10.  
  11. }
  12.  
  13. // Update is called once per frame
  14. void Update () {
  15. if (Input.GetKeyDown(KeyCode.RightShift))
  16. {
  17. check = false;
  18. draw = false;
  19. }
  20.  
  21. if (draw)
  22. Debug.DrawRay(hitMy.contacts[0].point, hitMy.contacts[0].normal, Color.red);
  23. }
  24.  
  25.  
  26. void OnCollisionEnter(Collision hit)
  27. {
  28. if (!check)
  29. {
  30. draw = true;
  31. hitMy = hit;
  32. if (hit.transform.GetComponent<InputDamage>() == null)
  33. return;
  34. Debug.Log("!!!! " + hit.contacts[0].point + "|" + hit.transform.GetComponent<InputDamage>().name);
  35. Debug.Log("!!!! " + hit.transform.GetComponent<Collider>().bounds.center);
  36. check = true;
  37. }
  38.  
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement