Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class testcollision : MonoBehaviour {
- bool check = false;
- bool draw = false;
- Collision hitMy;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- if (Input.GetKeyDown(KeyCode.RightShift))
- {
- check = false;
- draw = false;
- }
- if (draw)
- Debug.DrawRay(hitMy.contacts[0].point, hitMy.contacts[0].normal, Color.red);
- }
- void OnCollisionEnter(Collision hit)
- {
- if (!check)
- {
- draw = true;
- hitMy = hit;
- if (hit.transform.GetComponent<InputDamage>() == null)
- return;
- Debug.Log("!!!! " + hit.contacts[0].point + "|" + hit.transform.GetComponent<InputDamage>().name);
- Debug.Log("!!!! " + hit.transform.GetComponent<Collider>().bounds.center);
- check = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement