Wanting to find an AI for hostile mobs C#.

I am currently researching and experamenting to develope a mob AI that works as follows:

-In multiplayer games, it is always checking for nearest player,
-If the nearest player is close enough to the mob, then the mob begins to follow the player.
-Once the player selected is within range of the mob, it shoots arrows at it or uses some other method to kill the player.
-If the player runs away, the mob stops following the player after a certain distance between the mob and player is achieved.

I am wanting to make the script my own, but if you have any advice that could speed up the process, it would be much appreciated.

TO THOSE OF YOU WHO LIKE TO CRITISIZE PEOPLE WHO ARE ALLWAYS LOOKING FOR HELP:
Remeber, we all started as coding noobs, and knew nothing of it, and don’t tell me to go look up the answer, because I am already trying. I just have not found it yet.

Thanks in advanced.

What you are describing is essentially what you want to code. There are many different ways to achieve it however, which really depends on how you structure your game. Read about Behaviour Trees, Planning, GOAP and Utility AI. Those are techniques to produce autonomous behaviours by agents. You’ll also need to add in path finding, and probably some sort of a blackboard to keep track of players. A controller class to direct mobs is also probably going to be needed.

Without derailing your post, this is quite disrespectful. The problem is never about asking questions. The problem is about people not willing to put in the work to learn how to properly develop software. Before you can start making games, you should have a solid understanding on how programing works, concepts of software design, language features, Unity’s API and a whole lot of other subjects, ones that can take YEARS to study and get proficient at.

People (not saying you, this is a general comment) that decide they are going to make a game without even taking the time to read the MANUAL on how to use the game engine, and then spam the forums with questions. Also, a big part of programming is problem solving, so if a person can’t be bothered to do the basic ground work, how is he ever going to solve big scale problems that arise when you build a game?

Behaviour Tree (BT) is a nice tool to handle such AI.
Have a look at Panda BT:
http://www.pandabehaviour.com

The package contains example for doing idle-chase-attack behaviours.

1 Like