Search Unity

Server side battle simulation

Discussion in 'Netcode for GameObjects' started by Complex77, Mar 14, 2023.

  1. Complex77

    Complex77

    Joined:
    Feb 28, 2013
    Posts:
    33
    hi! id like to simulate battles serverside in my game and have clients render the simulation. whats the suggested approach for this?

    i figure networkbehaviours are out of the question, so what should i use to update the units and projectile positions?

    thanks!
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,990
    Details please! Not every „battle“ is the same.
    What brings you to the assumption that NetworkBehaviours won’t work?
     
  3. Complex77

    Complex77

    Joined:
    Feb 28, 2013
    Posts:
    33
    Hi, thanks for the reply.
    Id like to simulate the battles without having game objects here and there. A sort of backend running at the server. I might be wrong with this approach tho.
    Im hoping to have several battles running at the same time in different parts of the map with multiple units (im considering using DOTs for this as well)

    these battles would be realtime and have between 5 and 15 ships, with each ship having upto 10 fighters. So a maximum of 150 units plus projectiles per battle.

    Should i use NetworkBehaviours for the ships, fighters and projectiles? or something else?
    Thanks again!
     
  4. lavagoatGG

    lavagoatGG

    Joined:
    Apr 16, 2022
    Posts:
    229
    You don't have to have a physical representation of every network behaviour. Just create an empty gameobject, attach a networkObject component and a network behaviour script and the object will be able to sync data between server and clients. You can spawn one for each battle and pass data through network variables. Instead you can use network transform and animator for each unit.
     
  5. Complex77

    Complex77

    Joined:
    Feb 28, 2013
    Posts:
    33
    ok thanks!
    ill try that then :)