How to deactivate object with tag

So, im making a 2d fighting game and i made a tag called “Fist” and gave it to my player, and i want it so that when a enemy touches a object with the tag “Fist” it gets destroyed. im also fairly new to unity so any help will be appreciated. heres a snippet of what i got so far:

void OnCollisionEnter(Collision col)
    if (col.gameObject.tag == "Fist")

I cannot see something wrong with this code. However, instead of disabling the gameObject you could delete it completely with Destroy(gameObject). What exactly is your problem? If the code doesnt run right now you might check:
If there are colliders and rigidbodies on the objects(only one has to have a rigidbody in this case) . Is the tag “Fist” on the object that has a collider component? Based on if the colliders are trigger or not you might want to use OnTriggerEnter instead of OnCollisionEnter. I don’t know all of the scenarios of when you should use which one but I bet you will find a lot of information online if you google “When to use OnCollisionEnter vs OnTriggerEnter”.

Btw instead of doing col.gameObject.tag == "Fist you could use the compare tag function. So you could write col.gameObject.CompareTag("Fist"). This is a bit faster and better practise.

Make sure that:

  • both objects have colliders and they are not set to trigger.
  • the tag is set on the object correctly.
  • the script is attached to the correct object.

Other than that your snippet looks ok!