- Home /
If raycast hits object with tag
Hi,
I am inexperienced with ray casting and need some help. as it stands I am trying to make sure that when I click on one game object with a tag "one" it will do one thing, but if it hits andything else it will do another code. I have tryed this a cupple of time now and would like come help.
if (Physics.Raycast (ray, out hitInfo)) { //sets the layormask on the raycast.
//if (RaycastHit.collider.gameObject.tag ("one")) {
// do 1 code
//}
//else if (RaycastHit.collider.gameObject.tag !== ("one")){
// do other code
//}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613183221im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Bottom area of a 3D model? Raycast? 1 Answer
How to get the distance between two objects in feet/meter? 1 Answer
Mouse Click + Raycast + Colliders 2 Answers