OnCollisionEnter + animator problem (Solved)

This is my first try to make coding so I think I have done something real stupid here… This is what it should do:
When the enemy hits the player it makes boolean IsClose True which means enemy starts doing his attack animation. It just don’t activate the boolean :frowning:

using UnityEngine;
using System.Collections;

public class animatioon: MonoBehaviour
{

    Animator animator;

    // Use this for initialization
    void Start()
    {
        animator = GetComponent<Animator>();
       
    }

    // Update is called once per frame
    void Update()
    {
 
    }

    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.CompareTag("Player")) 
        {
            animator.SetBool("IsClose", true);
        }
    }
}

Make sure both of your objects have colliders and at least one of them has a rigidBody.
Also make sure you use Rigidbody2D if you use a Collider2D and a normal Rigidbody for a 3D collider.

run a debug to see if the collision is being detected. one in the method and on in the if statement within the method
if the debug in the shows up in the consolemethod but doesnt in the if statement then your physics is fine but your tag doest match and vice versa.

Thanks m8! I had made only capsule colliders…

@Craig8726 I’ll start to use that.