mirror of
https://github.com/0015/ThatProject.git
synced 2026-01-13 01:37:43 +03:00
22 lines
592 B
C#
22 lines
592 B
C#
using UnityEngine;
|
|
|
|
public class RayCaster : MonoBehaviour
|
|
{
|
|
void OnDrawGizmos()
|
|
{
|
|
float maxDistance = 10f;
|
|
RaycastHit hit;
|
|
|
|
bool isHit = Physics.Raycast(transform.position, transform.forward, out hit, maxDistance);
|
|
if (isHit)
|
|
{
|
|
Gizmos.color = Color.red;
|
|
Gizmos.DrawRay(transform.position, transform.forward * hit.distance);
|
|
}
|
|
else
|
|
{
|
|
Gizmos.color = Color.green;
|
|
Gizmos.DrawRay(transform.position, transform.forward * maxDistance);
|
|
}
|
|
}
|
|
} |