*
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class RaycastTester : MonoBehaviour {
|
||||
|
||||
public GameObject target;
|
||||
public float distance = 100;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
private void FixedUpdate() {
|
||||
if (target != null) {
|
||||
var src = transform.position;
|
||||
var dst = target.transform.position;
|
||||
|
||||
var hit = Physics2D.Raycast(src, (dst - src).normalized, distance, 1 << target.gameObject.layer);
|
||||
if (hit.rigidbody != null) {
|
||||
Debug.Log("!!!Hit collider: " + hit.collider.name);
|
||||
}
|
||||
else {
|
||||
Debug.Log("!!!Nothing hit");
|
||||
}
|
||||
|
||||
Debug.DrawLine(src, dst);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user