I guys im trying develop a simple AI for my game right know the player section is working fine, the melle enemy too, it have a chase range and an attack range, now im trying to work in a ranged enemy everything works fine but not im trying to instanciate a fireball(sphere) from enemy to player, right now i get fireball instantiated at the enemy position but it doesnt move. How can i make it follow player until it collides with player and then destroy the prefab?
Replies
So don't pass it the position of the player, pass it the player transform. Then it can always know where the player is.
public Transform target;
public float speed;
void update()
{
float step = speed * time.DeltaTime;
tansform.position = Vector3.MoveTowards(transform.position, target.position, step);
}