Question by
yonatan003 · Apr 11, 2020 at 09:40 PM ·
c#oncollisionenter
Why is OnCollisionEnter2D function running twice??
here is the code:
void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "forsenJoy") { Destroy(col.gameObject); healthAndStamina.Health -= ForsenJoyDamage; //healthBar.DamageHealthBar(ForsenJoyDamage); Debug.Log("Collision In: " + gameObject.name); } }
the code: isn't applied twice on different or same game objects the function: isn't called twice in the script
Comment
Answer by streeetwalker · Apr 12, 2020 at 09:01 AM
@yonatan003, did you solve this? We'd have to see more of your situation. There are a lot of things that could cause this to happen.
Your answer
![](https://koobas.hobune.stream/wayback/20220612231144im_/https://answers.unity.com/themes/thub/images/avi.jpg)