Cannot get collision to do anything

Good day fellow Uniters!

Haven’t used Unity since April, so I’m again confusing myself.

For some reason, I cannot get Collision to work :?

Script attached to my Cube (Which the player needs to walk into in order to test my Awesomely simple health script) as follow:

function OnCollisionEnter(collision : Collision) {
    if(collision.rigidbody){ 
	   gameObject.FindWithTag("Player").SendMessage("ApplyDamage");
	   print ("Hit!");
    }

And on the receiving side (Player) the following:

function ApplyDamage () {
Debug.Log("Hit!");
}

And VIOLA! Nothing happens :frowning:

I have RigidBodies attached to both the Cube and the Player, Cube also has a Box Collider.

If any Einstein replica’s are willing to ease my pain, I bake quite lekker cookies (Shipping Excluded) :slight_smile:

Thanks!

make sure you have a collider on both, and that one has a non kinematic rigidbody…

If that still doesn’t work, then try this script

function OnCollisionEnter(collision : Collision){
	if (collision.gameObject.tag == "Player"){
		gameObject.FindWithTag("Player").SendMessage("ApplyDamage");
    print("Hit!");
	}
}

alternatively, you can try this:

var collisionObject : GameObject;

function OnCollisionEnter(collision : Collision){
    	if (collision.gameObject == collisionObject){
    		gameObject.FindWithTag("Player").SendMessage("ApplyDamage");
        print("Hit!");
    	}
    }

Hope this helps…

If you need more help, then comment back…

-Grady