I am making a unity3d fps shooter i on my bullets is a trigger collider wich detects a gameobject with the tag Enemy but when i shoot it does not detect the enemy
here is my script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bulletscript : MonoBehaviour
{
public float Speed = 20;
private void Start()
{
StartCoroutine("Despawn",10f);
}
void Update()
{
transform.Translate(Vector3.forward * Speed * Time.deltaTime);
}
public IEnumerator Despawn(float DespawnTime)
{
yield return new WaitForSeconds(DespawnTime);
Destroy(gameObject);
}
// The
Problem !!!!!!!!
public void OnTriggerEnter(Collider Coll)
{
Debug.Log("HIT");
if (Coll.gameObject.tag == "Enemy")
{
Debug.Log("HitEnemy");
EnemyController Enemy = Coll.GetComponent<EnemyController>();
Enemy.health = Enemy.health - 10f;
Destroy(gameObject);
}
}
}