Quantcast
Channel: Answers by "IvovdMarel"
Viewing all articles
Browse latest Browse all 145

Answer by IvovdMarel

$
0
0
Replace the OnTriggerStay method with: void OnTriggerEnter2D(Collider2D coll){ if (gameObject.tag == "squarerow"){ triggered = true; } } void OnTriggerExit2D(Collider2D coll){ if (gameObject.tag == "squarerow"){ triggered = false; } } The OnTriggerStay only gets called when the trigger are colliding. Therefore, using the if-else within that method is wrong. The if-else refers to the other object having a tag of the name "squarerow", not to object colliding or not. EDIT: Also you need to fix the bug that you use gameObject.tag instead of coll.gameObject.tag. In both methods it should be: if (coll.gameObject.tag == "squarerow"){ triggered = false; }

Viewing all articles
Browse latest Browse all 145

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>