Hello 
I Am trying to make an attack system where when the enemy collides with the players hand, he dies. I have added a “Debug.Log” when he collides with the hand, but that message is not showing up? Here is my code:
void OnCollisionEnter(Collision col)
{
if (col.gameObject.CompareTag(“Impact”))
{
Debug.Log(“Hit”);
}
}
I have added a box collider to the players hand and tagged it with “Impact”. Thanks!
Start with the API reference for OnCollisionEnter() and make sure you are meeting all the requirements specified.
Also, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.
Doing this should help you answer these types of questions:
- is this code even running? which parts are running? how often does it run?
- what are the values of the variables involved? Are they initialized?
Knowing this information will help you reason about the behavior you are seeing.
1 Like
Hello! Thank You So Much! I tried doing what you said and it worked
Thanks again!
1 Like