Search Unity

Modifying and accessing client vars with Unet

Discussion in 'UNet' started by JD_Designer, Jul 14, 2017.

  1. JD_Designer

    JD_Designer

    Joined:
    Sep 1, 2015
    Posts:
    111
    Hi everyone,

    I'm attempting to learn Unet - I've read the manual and I've walked through a tutorial or two. Some of it is clicking, some of it is not.

    I want to create a simple multiplayer project: My scene contains a game object with a component that generates random float values at every update. This component should be generating different values in the host and clients respective scenes. There should be another class (that lives on the server?) that gets the float values from both host and client and returns the sum. The sum is stored in a variable that can be accessed by a non-networked script in the respective scenes.

    The tutorials I've done so far have been a great source for learning about spawning, player transforms, etc, but I still don't understand how to pass and modify variables across the server yet. Should I be looking here? Any help is appreciated. Thanks!
     
  2. JD_Designer

    JD_Designer

    Joined:
    Sep 1, 2015
    Posts:
    111
    So would I...
    1.) create a prefab object (with network identity(server only)) that contains a script (addManager) component for adding the floats generated by the two clients and...

    2.) spawn the "addManager" object on the server and somehow have the local scripts in my instanced scene (host and client) feed it the float values and access the result?

    Sorry. Very new to multiplayer.