Adding Bots to multiplayer games

Been doing the Unity RTS Multiplayer course. I think a nice extension to this course would be to see how to add computer controlled players to what is by default a multiplayer game, eg to “fill up the lobby”. I think building a multiplayer game that you can play single player makes more sense than making a single player game and trying to convert it into a multiplayer game. At the moment each connection gets allocated as a player, but it’s unclear to me how you could have “players” that aren’t created from a connection / how to decouple player entities from connections and treat an AI “enemy” in the same way as a human “enemy”.

2 Likes

Hi there, great suggestion. The link below is the suggestions forum for GameDev.tv. I am encouraging people to post and vote for their ideas there to build up some steam on the more popular ones.

For everyone interested: Today I tested a bit around with “fake players” for enemy ai. Turned out that this is relatively easy to do.
The main problem is the current owner check. Every owner check uses the connectionToClient (or hasAuthority) which doesn’t work for ai players because they are owned by the server and thus connectionToClient is null. To solve this problem I added my own kind of NetworkIdentity (besides the normal NetworkIdentity) that just stores the id of his owner. So everytime a unit or a building or any other owned object is spawned the server assigns the owner id and for every owner check I now simply compare owner id’s.
Of course there are some other minor problems (mostly ui stuff and spawning logic) and the fake players don’t do anything by default (making the actual ai is far from easy) but I hope this gives some of you at least a point to start. :slight_smile:

2 Likes

Privacy & Terms