New to Scripting with Unity, Need help with Character Controller collisions

Hello,

I’m new to scripting with unity and I’m trying to get a very simple collision to work but I can’t seem to get it right. I simply have a character controller object and another object that I want it to collide with and then log something to the debug console. So far I’ve had no luck, here’s what I’m using:

function OnControllerColliderHit(hit: ControllerColliderHit){
	if(hit.gameObject.CompareTag == "Obj_Spike") {
		Debug.Log("Hit Spike");
}
}

This script is on the player object, nothing happens when they collide. Help would be appreciated.

CompareTag is a function not a property, so try:

if(hit.gameObject.CompareTag("Obj_Spike")) {

This causes the error:

UnityException: Tag: Obj_Spike is not defined!
Player Collisions.OnControllerColliderHit (UnityEngine.ControllerColliderHit hit) (at Assets/Scripts/Player Collisions.js:5)
UnityEngine.CharacterController:Move(Vector3)
Player Script:Update() (at Assets/Scripts/Player Script.js:29)

To appear

Have you added the tag to the tag manager and applied it to your object?

No, I honestly don’t even know what a tag is… why is detecting a simple collision so difficult?

I think you should look up some Unity3D tutorials first before venturing out on your own.
Here’s some info on the tag manager: Unity - Manual: Tags and Layers

I would if I had time, I have a prototype due tomorrow and I’m in way over my head here. Thanks for the help anyway