Collisions won't register?

Hi.
I’m making a simple Pacman-like game where I want an object to be replaced with another when the player collides with it. I’ve figured out that I should destroy the original object and spawn the other object in the same transform.
However, for whatever reason, I can’t get the game to register the collision at all. I’m quite stumped, as it seems to be an incredibly simple piece of code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HouseScript : MonoBehaviour {

	// Use this for initialization
	void Start () {
		
	}

	void OnCollisionEnter(Collider col) {

		if (col.gameObject.CompareTag ("Player")) {
			Debug.Log ("awake");
			Object.Destroy (this.gameObject);
		}
	}
	// Update is called once per frame
	void FixedUpdate () {

			
	}
}

Can anyone please help out?

There are couple things you need to check:

  1. Make sure you have a RigidBody component on your Player
  2. Make sure you have a Collider(ex: BoxCollider) on your HouseScript gameObject
  3. In your example code, you should be using Collision Type as your callback type.

<pre> void OnCollisionEnter(Collision collision){ if(collision.gameObject.CompareTag ("Player")) { Debug.Log ("awake"); Object.Destroy (this.gameObject); } } </pre>

Like jasonlu00 said, you might want to change the Collider to Collision, but also you might to make sure that BOTH the player and the object has a rigidbody and a collider.
If it still doesn’t work, go to the rigidbody component on the player and set the Collision detection to continuous dynamic and set the other object’s collision detection to continuous (this will make sure they collide even if the player is moving fast).

HOWEVER, what you want to do might be better done with OnTriggerEnter:
All you need to do is tick the isTrigger option on the object’s collider component and change the OnCollisionEnter to OnTriggerEnter.

    void OnTriggerEnter(Collider col) 
    { 
             if (col.gameObject.CompareTag ("Player"))
            {
                 Debug.Log ("awake");
                 Object.Destroy (this.gameObject);
             }
         }