- Home /
I need help with Trigger collision detecting tags
So I'm making a (3d) tile swap game (think bejeweled) and I've got a method for detecting rows or columns of 3. Each spot occupied by a tile (in this case, called buttons) also has an invisible gameobject with a trigger box collider. Each button (tile) also has a trigger collider. Both have rigidbodies. I want to have the invisible objects check what tag the object they are colliding with has, then proceed accordingly. Code:
function OnTriggerEnter(other: Collider) {
Debug.Log("detected Trigger");
if (other.tag == "red" ) {
Debug.Log("1 red detected");
x += 0.05857;
if (other.tag == "red") {
x -= 0.11714;
if (other.tag != "red") {
x -= 0.05857;
y-= 0.05857;
if (other.tag == "red") {
}
}
if (other.tag == "red") {
Debug.Log("3 reds detected");
other.tag = "uncolored";
}
}
}
}
I'm getting the message for detecting a collision, but it doesn't know the tag so isn't saying it detected a red.
http://docs.unity3d.com/ScriptReference/Component.CompareTag.html
$$anonymous$$ake sure that 'uncolored' is entered in the list of tags and check the objects have the tags set. Also, its case sensitive. Oh and use Comparetag for the actual comparison.
Your answer
Follow this Question
Related Questions
get only one colliding body 3 Answers
How to get OnTriggerEnter effect without using isTriggered on Collider? 1 Answer
(Virtual reality) Collision fighting when tunneling - Any ideas? (gif included) 0 Answers
Gameobject not detecting collison from other Box Collider 2D [SOLVED?] 2 Answers
Makign an object collide continously 1 Answer