Hey, I will get to the point : I have script that makes Enemy move towards my Player (it is 2D platformer). Enemy move if distance between Player and object is less than max dist. but if I reach higher value with my Player than max dist Enemy stops following.
if (Vector2.Distance(transform.position, Player.transform.position) <= 10)
{
Vector2 enemyVelocity = new Vector2((transform.position.x - Player.transform.position.x) * Speed, 0);
rgBody2d.velocity = -enemyVelocity.normalized * Speed;
anim.SetFloat("Speed", enemyVelocity.magnitude);
}
How can I make follow my player if it shows in Camera and do not stop until it reaches the Player?
Anyone who can explain?