- Home /
Question by
el-mas-pro-470 · Jan 23, 2019 at 05:59 PM ·
raycastenemyraycastingtargetsight
Raycast target sight?
Hello! i recently make a raycast enemy vision camp, but.. How to i make target in sight? (player) thanks!
using UnityEngine;
using System.Collections;
public class EnemyRaycast : MonoBehaviour {
Ray ThugRay;
RaycastHit RayHit;
public float Distance;
public float DetectedDistance;
public bool Detected = false;
void Start ()
{
}
void Update ()
{
ThugRay = new Ray(transform.position, transform.forward*Distance);
Debug.DrawRay(transform.position, transform.forward*Distance, Color.red);
if(Physics.Raycast(transform.position, transform.forward, DetectedDistance))
{
Detected = true;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Enemy line of sight 1 Answer
Trouble with Raycast shooting 1 Answer
Raycast to OVRplayercontroller,Raycast to OVRplayercontroller - bugged 1 Answer
Ray Cast Click on Enemy - Change Current Target 1 Answer
Follow Nearest Target 1 Answer