Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Send object reference from server to client

Discussion in 'Multiplayer' started by VincentAbert, Jan 13, 2022.

  1. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    123
    Hello everyone !


    After a few weeks of getting to know MLAPI, I’m pretty satisfied with what I’m managing to do with it ; but today I just got stumped trying to do the simplest thing… I don’t know if I’m just tired, but it feels like I’m missing the obvious.

    Here is the situation (simplified) :

    A client calls a server RPC → the server does some logic to figure out a target (another player object), and has a reference to the object, its client id, etc. → how do I send the target back to the original client ? My initial solution was to call a client RPC sending the client id, and just retrieving it locally, but you can’t access the connected clients list if you’re not the server.


    Any simple way to send a reference (or a way to get the reference) to a player object from server to client ?


    Thank you !
     
  2. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    656
    VincentAbert likes this.