Files

36 lines
800 B
C#
Raw Permalink Normal View History

2025-05-13 05:19:58 +03:00
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 () {
}
}