so im making a survival game and i want an ax to be able to destroy (“kill”) a sheep when the end of the axe collides with the sheep. so i used…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class sheepScript : MonoBehaviour {
public GameObject foodSpawn;
public GameObject food;
void OnCollisionEnter(Collision col)
{
if(col.gameObject.tag.Equals("axe"))
{
Destroy(gameObject);
Instantiate(food, foodSpawn.transform.position, foodSpawn.transform.rotation);
}
}
}
`
this exact same script works fine with the player but not with the ax (i don’t want it where i walk into sheep and they dye)
how do i fix this…
If you take a look at the documentation ( 1): "Collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached ". So your axe might need to have a rigid body attached to it.
Another solution i can think of is, using a collider and setting its isTrigger to true (tick the checkbox). Then you can use onTriggerEnter to check when the axe has collided. (Although you may need to make the axe collider just a little bigger so that it actually enter into the collider of the sheep).
Hope this helps. 
Thank you that’s probably the problem can’t test it at the moment but that sounds like it makes sense so thx.
Once again thx:)