- Home /
How can I make a ray stop uppon reaching a trigger?
Hi, I have a 2D scene that has two objects (one behind another), they both have a tag to which ray responds. That messes my game mechanic. So I'd like to stop a ray upon reaching the first tag. Thanks in advance!
Answer by dan_wipf · Aug 25, 2018 at 10:59 AM
make a bool. if (bool = true) ray can be casted, if tag was found set the bool to false. @FLEDD_Fran if you need more explenation let me know.
Yeah, but still ray passes through both tags and that creates an error. Because: if(hit.transform.tag.Equals ("Finish")){ //Destroys an object } if(hit.transform.tag.Equals ("Respawn")){ //Spawns object } This is only a presentationm of code.
And these ifs contradict each other, but ray still gets both tags.
No need. I figured it out finally. Thank you so much!