How would I make advanced NPC ai?

I’m making a game that uses swords and magic with a block parry dodge system. I was wondering how I could make monster AI for the game. I mainly need help on:

  1. detecting an enemy
  2. switching enemies when hit
  3. pathfinding
  4. stopping when in a certain range
  5. basics such as anims, morphs
    I can take care of the combat system myself but those 4 I have no clue where to start. I have never made an NPC AI before, especially not an advanced one such as this.

Also, if you need a reference, I was thinking of Deepwoken’s mob AI where the NPC constantly follows the player regardless of if it can find a path through or not. (for a while before giving up)

I never done advanced NPC AI. However, I got some ideas that may help with your thinking. I never played deepwoken so I don’t understand your reference lol.

Use a circle/part (your choice) and attach an event to it, handling whatsoever when something is near there. You may want to use CollectionService to tag the instances for example “NPC” tag, the event connected to it will check if it has this tag. If so, performs a action.

I don’t really know what you mean by this. I’d assume you just add some custom events to detect if you hit it?

Back to the part where I told you to attach a part to the NPC to detect an enemy is within range. Stop the code when the NPC stopped touching the part.

Those for you to figure out, go on Roblox documentation.

PathfindingService | Documentation - Roblox Creator Hub.
Or I suggest you to use some custom open source modules for pathfinding because Roblox itself does a really bad job implementing pathfinding and bugs occur occasionally (idk, thats what I heard other people say).

Go ask chat GPT, I don’t know if it will help but try it.

1 Like

You will need to learn magnitude and pathfinding, you will also need to learn animations and combat system.

1 Like

If you’re making AIs that learns, then go ahead and check out this resource.

1 Like

I think hes using the wrong term honestly. He might just be looking for a algorithm because I don’t really see the point of machine learning when you can just implement this yourself (or im just dumb)

1 Like

you’re right. What I’m looking for are specific ways to make my enemy AI do the tasks I have listed. Useful help would be: example code, pseudocode, examples, or public resources.

1 Like

don’t use the term AI. Since AI needs deep learning (which is something I never learned and is a advanced topic I would never want to touch). While algorithms are a way to perform what task you want them to do but in a complex relationship.

1 Like

I answered something similar a while back. While only a basic example, my response there might be of some help

Additionally, you could look into using some community resources like this one (note I’ve not used it, but certainly something I’d consider)