Search Unity

How to run a headless server in the Unity editor for a level other than level_menu?

Discussion in 'FPS.Sample Game' started by rsud, May 30, 2019.

  1. rsud

    rsud

    Joined:
    Aug 13, 2010
    Posts:
    85
    I've got the FPS Sample up and running.

    in Project Tools Quick Start, if I select Level_01 for Level and for 'Use Editor As' I select Server when the client starts it crashes with a null reference exception. How can I run level_01 or a level I add in the Unity editor?
     
  2. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    51
    Did you build the levels first?
     
  3. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    141
    Howdy @rsud
    I put a video up a while ago, but I think it still is valid.

    Check it out!


    /Wave @karstenv!
     
  4. rsud

    rsud

    Joined:
    Aug 13, 2010
    Posts:
    85
    Yes, everything is working and I am able to run the FPS sample game. I've added my own level and have the terraformer and robot running around on a surface (thank you Aggressive Mastery!).

    I am having a problem when I start the server in the unity editor and click 'CREATE GAME' and then select LEVEL_01 and de-select 'HEADLESS SERVER' then click 'CREATE GAME'.

    When I run a client and JOIN GAME and I click to connect to the server (running in Unity editor) the client crashes. Crosshairs show up on the client screen and then I'm in the client console looking at errors. Adding a screen shot.

    Why this crash? Is there another way to run the server in the editor?

    ClientError.jpg
     
  5. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    141
    Hello @rsud

    Hmmmmm, well I think your errors show on line #623-624 that the server loaded.

    If you created a new level, named Level_01, and left the oold level_01 in there... You may have both, and should most likily just rename your level to level_02 and update the links (the editor to load level 02, the menu to have level_02 ect.)

    You may have two level_01 in your game, which could cause this confusion?

    Additionally, that error often means "Hey, we are loading this item, but its not the EXACT SAME as the server - you prolly need to rebuild everthing at the same time" or "hey, we are trying to load this item, but cant find it... aka you didn't compile with it or its not in the item registery"

    Did you add anything besides the level, like movable objects ect? If you are using more items in the FPS sample, you may have wondered into registery issues. If you hit "prepaire registeries" that can resolve it.

    I think its in the FPS-Sample menu under registeries.

    Get everything compiled, no name conflicts, and registered... should remove null references (refferences to null or nothing)

    Also, like the video says, this assumes you used GIT LFS and downloadeded the whole project. If you use any other menthod, like Git Clone from the website, you ARE missing vital files which were not downloaded, and that IS causing this issue.