Search Unity

Changing level on server

Discussion in 'FPS.Sample Game' started by minibotan, May 6, 2019.

  1. minibotan

    minibotan

    Joined:
    Oct 4, 2016
    Posts:
    15
    Did anyone of you made level changing feature in your games based on FPSSample?

    Now i have DM gamemode and 3 maps, but i can play only on one of them(to play others i should run anoter server). I want to make change_level command to change levels after round is finished. Main problem is that i dont really know how to make that, so your advices will be really helpful to me.
     
  2. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    51
    There is a runatserver command that you could use.
    On the server you can load any maps using load level....

    I havn't tried it but something like, from the clients console:

    runatserver load levelname
     
  3. minibotan

    minibotan

    Joined:
    Oct 4, 2016
    Posts:
    15
    i don't know why, but that does not work and crashes the server.
    maybe that is my fault and i should despawn all that replicated stuff before changing the level.
    here the result of
     
  4. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    51
    Try to type help in the console. Perhaps there is a command to unload the present level first.
     
  5. minibotan

    minibotan

    Joined:
    Oct 4, 2016
    Posts:
    15
    yes, there are unload but it is not implemented yet..

    Code (CSharp):
    1. void UnloadLevel()
    2.     {
    3.         // TODO
    4.     }

    Also i found boot command, that unloads current level and shutdowns and disposes all the stuff that should be.
    I think i'll just get some code from there to unload current level.
     
    karstenv likes this.
  6. AscendanceCapital

    AscendanceCapital

    Joined:
    Jul 25, 2016
    Posts:
    5
    Did you ever come up with a solution?
     
  7. minibotan

    minibotan

    Joined:
    Oct 4, 2016
    Posts:
    15
    nope =(
     
  8. AscendanceCapital

    AscendanceCapital

    Joined:
    Jul 25, 2016
    Posts:
    5
    We have dug deep into this build. There’s no easy solution in our opinion. This will be an extremely high level modification utilizing the scene management systems that have been implemented. If your new or not a pro I wouldn’t even bother attempting it. There’s very little documentation on some of the new processes that have been implemented. That being said we have learned an awful lot about how this program works lol. Maybe the unity developers have some insight into how to go about this.
     
  9. xkinginthecastlecastlex

    xkinginthecastlecastlex

    Joined:
    Nov 7, 2018
    Posts:
    80
    this would be very interesting for me as well - when a match is finished to automatically change the scene. I would very much appreciate any hint
     
  10. minibotan

    minibotan

    Joined:
    Oct 4, 2016
    Posts:
    15
    you can send to clients reconnect event and then disconnect them,
    after that you should run "boot" and then "serve level_name".
    and on client side after recieving reconnect event you should reconnect to the last server.

    that is the easiest way i know.
     
  11. xkinginthecastlecastlex

    xkinginthecastlecastlex

    Joined:
    Nov 7, 2018
    Posts:
    80
    thanks for your fast reply! have you been able to achieve it this way?
    Could you please give me some more details

    thanks a lot!
     
  12. minibotan

    minibotan

    Joined:
    Oct 4, 2016
    Posts:
    15
    i haven't time to make this stuff, so i don't know many details.
    i just minded up possible ways to make this happen.
     
  13. xkinginthecastlecastlex

    xkinginthecastlecastlex

    Joined:
    Nov 7, 2018
    Posts:
    80
    ok, thanks a lot. I will have to deep dive into this, as soon as I have a working solution I will share it here (if someone is able to achieve level switch after a match is finished it would be great to know how to achieve that)