Quantcast
Channel: Questions in topic: "gameobject.tag"
Viewing all articles
Browse latest Browse all 95

[C#] Raycasts and Object Tags

$
0
0
I have this code that cast three rays in font of an ai to check if there if something there. then if something is there. Physics.Raycast(transform.position, left, out lhit, StayD); Physics.Raycast(transform.position, fwd, out hit, StayD); Physics.Raycast(transform.position, right, out rhit, StayD); if(hit.collider.tag == CTag && lhit.collider.tag == CTag && rhit.collider.tag == CTag) transform.Translate(Vector3.forward * Time.deltaTime * MoveSpeed); this code was intended to make the ai move forward if the object in front of it has the same tag as the string CTag, and not move if any other object is infront of it, and move when there is nothing infront of it. i am not sure of how to do this, can any one help me.

Viewing all articles
Browse latest Browse all 95

Trending Articles