OnCollisionEnter() not getting called between two rigid bodies

void OnCollisionEnter(Collision other)
print (“enemy hit”);

i’m very new to Unity,basically building my first game.
in my game i have a PreFab(enemy) , that gets created N number of times and is a sphere .
i have another sphere, the main character, which when collides with the enemy/s, it should destroy that enemy, but the OnCollisionEnter() does not get called.
and both of them are in motion, the player is in circular motion and the enemy in a staright line towards the centre of the circle around which the player revolves.
details about prefab and player

PreFab(enemy): sphere, sphere collider,rigidbody
player: sphere, sphere collider,rigidbody

any suggestions would be helpful.


try: if (other.CompareTag("enemy"))
Or are you sure your tag is “enemy” not “Enemy”? Maybe its only a little typo. :slight_smile:

It may be that the tag you are looking for is “Enemy” or that you don’t actually need the transform, just other.CompateTag(“Enemy”).

I finally got mine to work by changing other.gameObject.tag == "Enemy" to access the collider: other.collider.gameObject.tag == "Enemy":

void OnCollisionEnter(Collision other){

		if(other.collider.gameObject.tag == "Enemy"){