Search Unity

How to avoid full headless server with bots?

Discussion in 'Multiplayer' started by grnbriar, Nov 24, 2009.

  1. grnbriar

    grnbriar

    Joined:
    Nov 16, 2009
    Posts:
    34
    I'm trying to understand the options for AI bots in a multiplayer game. Specifically AI movement and collision with terrain.

    For players - the client does all the collisions and gives me the position which I sync to other players. Most game interactions are just data lookups with random elements (damage awarded, loot found). All this can be scripted on the server side. (Using SmartFoxServer Pro)

    But now I'm trying to add server controlled patrolling bots. I can test for when a player is close, but the bot's default movement requires collision detection to the terrain and other objects plus when they run after players and then return if they are not killed.

    The only method I know to do this is to have a 'server-client' (headless server) that is the owner of all the server spawned bots that is manipulating these as their owner and syncing this out to real clients via the server. All my AI logic will run here. Only bots are instantiated on this client and only as collision meshes only. The server script itself tests for distance between bots and players and triggers bot activity as needed.

    I'm trying to avoid instantiating all players on a headless full server as the server will slow with added players. Only running the bots keeps the server speed unchanged. So only the script and network activity go up with added players, which I can run on more than one fox server, talking to the same bot client, so share the world with more clients.

    Is there a better way to implement server side controlled movement - to guarantee NPC movement is synced to all clients?

    I have not been able to find info on this subject anywhere, so I've been making it up as I go, usually not the best approach!

    David
     
  2. Lab013

    Lab013

    Joined:
    Oct 22, 2008
    Posts:
    405
    Have each player run their own bots that sync with other players.
     
  3. grnbriar

    grnbriar

    Joined:
    Nov 16, 2009
    Posts:
    34
    So 6 players in the same area each control the local bots? Who is the bot owner? And what when they log out or leave? A lot of ownership transfer it would seem. I don't really understand how that would work.
     
  4. Lab013

    Lab013

    Joined:
    Oct 22, 2008
    Posts:
    405
    Destroy a bot when the player leaves, and recreate it under another active player. Then restore the bots settings to that of the previous bot. Usually in a situation like this though, it is best to have a actual client run the server in a situation like this.