Search Unity

How to respawn a character, control him and connect him to server using FPSSample networking layer

Discussion in 'FPS.Sample Game' started by allenWTF, Dec 6, 2018.

  1. allenWTF

    allenWTF

    Joined:
    Mar 16, 2018
    Posts:
    8
    Hello,
    I want to make a simple level where we have a character (for now capsule will be fine) that the users can control. Also I'm not very sure how they have to be connected to server.

    This is what I've tried so far:
    I have successfully created an empty level and added a capsule to scene. Then I tried to apply to this capsule Replicate Entity and Movable script (just like in this question). Unfortunately, I wasn't able to connect to server. I've got some error about type of Guid (which I'm not sure how to set correctly either).

    Maybe someone already tried to figure out how to use only networking layer which Unity provied in this sample? That will be pretty interesting to see as well.

    Thank you!
     
  2. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    206
    Howdy Allen, I'll get a video up on some networked exploding cars (bodies, not car controller yet
    ) next week, which hits what you are working on I think. I am also surprised you are not just using the pre-build characters and spawn points... But anyway.

    As for the GUID issue, your NEW prefab/item needs a unique GUID, which is given to it when you register it via the replicated entity "register" button. Then build it all, and the GUID stuff should go away.

    Each unique prefab, needs to be given a unique GUID.

    Learning like this, I'm definitely starting with the FPS Sample and ripping it down, instead of trying to piece it together on an empty plate.
     
    Last edited: Dec 6, 2018
  3. allenWTF

    allenWTF

    Joined:
    Mar 16, 2018
    Posts:
    8

    Thank you for your answer! Sorry, but where exactly is this "register" button. Or this has to be done through coding? Because when 'im applying Replicated entity to game object all i can see is guid and Net Id fields.
     
  4. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    206
    When you create a new prefab(just a collection of object), and then drag it into your assets folder to become a prefab. That dragging to become a prefab- enables the ability to register that prefab with the multiplayer-entity registry so it can be synced between clients and the server. So you cannot network-sync non-prefabs.

    So if you have "Replicated Entity" on the root (base) of the prefab, when you click then "open prefab (in prefab viewer)" you will be able to then "unregister" and "register" that prefab for network sync.

    Attached is a picture of the van, and you can see it in the prefab viewer, and that I have not registered it yet. Since it is not registered yet, if I tried to use it, it would give me error and not load (like missing GUID and nulll enties and all sorts of stuff.) So I will need to register it by hitting that button. But the registery is... ah, a WIP (it was just redesigned in fps 2.0)

    Each prefab as its own unique GUID/Replicated entity. FYI

    Good luck!
    -Micah
     

    Attached Files: