I'm a beginner who just started Unity.
I'm making a game with Unity, but I'm worried because I can't judge when the player and Enemy collide.
Specifically, the player's code is
void OnTriggerEnter 2D (Collider 2D col)
{
if(col.gameObject.CompareTag("ground"))
{
Debug.Log("Landing";
}
if(col.gameObject.CompareTag("Enemy"))
{
Debug.Log("Collision");
}
}
However, if you look at the log, the landing on the ground is going well, but the log says "collision" twice even though there should be only one collision with Enemy.
How can one collision be handled once?
Thank you for your cooperation.
Is it a collider issue that is being used?
Please refer to this.
https://answers.unity.com/questions/1474400/ontriggerenter2d-gets-called-twice-sometimes.html
© 2024 OneMinuteCode. All rights reserved.