Question by
ConnectionFaild · Oct 16, 2016 at 12:45 AM ·
scripting problembug-perhaps
OnTriggerEnter2D tiggers twice
I'm using simple debug message
void OnTriggerEnter2D(Collider2D coll)
{
if (coll.gameObject.tag == "Letter")
{
Letter letterObject = coll.gameObject.GetComponent
();
print(name + " enter " + letterObject.letter);
}
}
void OnTriggerExit2D(Collider2D coll)
{
if (coll.gameObject.tag == "Letter")
{
Letter letterObject = coll.gameObject.GetComponent
();
print(name + " exit " + letterObject.letter);
}
}
Letter is just a script that contains char field. Trigger works fine most of the time, but (!) when i'm applying force (jumping) to object (player) when it's already triggered i see that:
Player enter s //applying force Player enter s Player exit s Player exit s
Comment
Can you provide us with a bit more information? What objects is the script attached to?
Your answer
![](https://koobas.hobune.stream/wayback/20220612094717im_/https://answers.unity.com/themes/thub/images/avi.jpg)