Coin Counter still not working after 5+ hours of frustrating changing code and moving stuff around

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{


    public int currentCoins;
    int maxCoins = 22;

    void OnGUI()
    {
        GUI.Label(new Rect(10, 10, 150, 50), "Coins Collected: " + currentCoins + "  /  " + maxCoins);
    }

    private void OnCollisionEnter(Collision col)
    {
        currentCoins = currentCoins + 1;
    }


}

Here is my code. I’ve linked it to every different part of my dude, and it never works. I’ve tried combining the scripts and linking scripts together, nothing has worked. I’m trying to make everytime my character hits a coin (I’ve changed it to every object because coin wasn’t working) for the gui score counter to go up. What am I doing wrong? Very frustrated. Thanks. Literally all I want to do is detect when I collide with an object tagged coin, or even just check if I collide with anything at this point. I;ve made working teleporters that use the exact same code and principles so why doesn’t this work in any form

Are you using 2D or 3D colliders? You’re using the 3D version of the OnCollisionEnter method, so you must use a non-trigger 3D collider (a collider that doesn’t have the 2D suffix in it’s name). As you’re using OnCollisionEnter, you must also have at least one non-kinematic rigidbody on either of the colliding objects (probably the player in your case).

You should first and foremost check your colliders and their settings. If any of them are trigger colliders, this method won’t work, so you must either make them physical (non-trigger) colliders OR you should be using OnTriggerEnter instead.

It’s also always good to read up on documentation in case you are having problems:

Make sure the following things are set up correctly:

  1. The object to which this script is attached must have a collider (if using mesh collider Check the convex option if unchecked)
  2. he object to which this script is attached must be having a rigid body, with “iskinematic” option un-checked
  3. The collider’s “IsTrigger” option must be un-checked
  4. If all of the above settings are correct, then go to Layer Collision Matrix and check if there are layers which are set to not detect some other layers