How do I make a enemy NPC with a radius?

So uh im pretty confuzzled on this one. I’ve been looking around for enemy NPC videos which yes there is. I have made some in the past and now im making a fighting game and I want to make good ones. When I mean good ones I want to create one with a so called radius around it so when you get close to it it chases after you and when your out of its range it stops. I have made a zombie before but it just always chases with no radius on it which it can see you. I am hoping you guys can give some information on the radius thing. It would also be nice if it can use path finding. Thanks

You can continuously check if a player is in range by using a magnitude check and a while loop (example of magnitude below);

if (Zombie.Head.Position - player.Character.Head.Position).Magnitude <= distance then

But player where would I be getting player from a script?

I think I got it…

y using magnitude, when you can use player:DistanceFromCharacter(enemy.HumanoidRootPart.Position), it make cleaner code, and it well optimized than magnitude

1 Like