hi all
any one can help?
i have an wall that one side is enemy and other side player stand.
i want to sent an raycast or line cast from enemy that when my player go other side of wall my enemy detect it and print (“a”).
any one has idea?
thankful.
I don’t know if I understand you well but try this:
//Your enemy gameobject must have this script attached and the Player needs to be in the LayerMask defined as Playermask:
var Playermask : LayerMask;
function Update () {
var fwd = transform.TransformDirection (Vector3.forward);
if (Physics.Raycast (transform.position, fwd, 5 ,Playermask )) {
print (“a”);
}
i do this but it dont print a
Vector3 fwd=transform.TransformDirection (Vector3.forward);
if (Physics.Raycast (transform.position, fwd, 50f ,playerMask )) {
print ("a");
}
You know you have to assign your player to the Layer “playerMask” (you will have to create) in the Inspector.