Hi guys below is my bullet code
using UnityEngine;
using System.Collections;
public class bullettower : MonoBehaviour {
public float speed = 10.0f;
Transform destination;
[SerializeField]
int _damageDealt = 10;
// Update is called once per frame
void Update () {
if (destination == null) {
Destroy(gameObject);
return;
}
float stepSize = Time.deltaTime * speed;
transform.position = Vector3.MoveTowards(transform.position, destination.position, stepSize);
if (transform.position.Equals(destination.position)) {
Health enemyHealth = destination.GetComponent<Health>();
if (enemyHealth != null)
{
enemyHealth.Damage(_damageDealt);
}
}
}
public void setDestination(Transform v) {
destination = v;
}
}
Im able to run the game but the problem is i spawn alot of medkit after killed the enemy like in this picture
. Do you guys have any idea whats wrong with it?