How can I start creating a bot that:

Good morning,
I need some help getting started with creating a behavior for my game.

The idea is a Top-Down and FPS multiplayer 2vs2 game.
I want to implement a system so that, if no players are currently online, 3 bots will be spawned as replacement players.

Right now, I’ve already got the two bots for the enemy team working.
Now I want to create the bot that is on the player’s team. This bot should have more advanced behavior, and here’s my question:

How can I start creating a bot that:

  • Follows the player
  • Keeps a certain distance behind them (without getting ahead)
  • Can take random positions near the player, staying close enough to act like a real teammate

I’m not sure if there are extensions or plugins available to make bot AI management easier.

1 Like

Well i know how to make the AI bot follow the player, to do that you need to install the behaviour on the AI : pathfinding.

So the next step depends how you want it to happen. If you want it to follow the player if the player is close (to a certain) distance or just follow it. If you want it to follow it if its close to a certain amount if pixels (if you dont you dont need any conditions) you need to add the condition to the Ai: if distance to object(Player) = 400. (you can edit this if you want 400 is example)
Then add action to AI: Ai move to position: X= player.X() Y= player.Y()

Also you can add action to change the speed if you want.

Side note, if you have walls in the game add the behaviour : pathfinding obstacles to it, so when the ai chases the player it goes around it.

1 Like

Alright, got it. Thanks for your help.
I have one last question: can you tell me how I can better manage the bot system?

Attached is my test code.
Currently, in the scene I have 3 bots:

player1

player2Enemy

(another bot)

I’d like to implement a logic so that:

The number of bots spawned automatically adjusts based on the number of human players in the match.

This also means I’ll need to figure out how to assign each bot to a team:

Police

Enemy
[


1 Like

ummmmmmmmmmmmmmmmm… yea idk really srry but u gotta ask someone else im really srry. But i have no clue when it comes to multiplayer… :sweat_smile:

ok thanks anyway! :wink:

1 Like

I’m sure there’s a multiplayer condition to detect the number of actual players…I did do this once but a while ago. And then you can repeat event ( 4 minus number of players)…create bot and number them using a scene variable

2 Likes

Thanks I’ll do a test :wink: