i’m making a simple FPS game as a test for my skills. The enemies are supposed to shoot fireballs.
When they hit an object, the are supposed to get destroyed. But they phase through the walls!
Can you help me fix it? thanks in advance.
The code:
using UnityEngine;
public class Fireball : MonoBehaviour
{
public float speed = 10.0f;
public int damage = 1;
// Update is called once per frame
void Update () {
transform.Translate(0, 0, speed * Time.deltaTime);
}
void OnTriggerEnter(Collider other)
{
PlayerCharacter player = other.GetComponent<PlayerCharacter>();
if(player != null)
{
Debug.Log("WHAT");
Destroy(other.gameObject);
}
Destroy(other.gameObject);
}
}