So I’m making a game where you cook food while defending it against people trying to take your food. Long story short I’m currently working on the people being spawned and I try to shoot them but it doesn’t work. I have colliders on both of the objects as well as RigidBodies. They are not marked as triggers and even when my bullet collides with something else it doesn’t work (I tested with Debug.Log). Here is my script for my bullet.
using UnityEngine;
public class Bullet : MonoBehaviour
{
public float speed;
private void Update()
{
transform.Translate(Vector3.forward * speed * Time.deltaTime);
}
private void OnCollisionEnter(Collision col)
{
Debug.Log("Works");
if (col.gameObject.tag == ("Enemy"))
{
Destroy(col.gameObject);
Debug.Log("Works even better");
}
}
}
I don’t have an enemy script yet. All of the enemies have that tag too. I tested with triggers and that didn’t seem to change anything.
PLS HALP ME!!!