Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

How can I spawn or highlight an object for only one player?

Discussion in 'Multiplayer' started by Fikule, Jan 9, 2018.

  1. Fikule

    Fikule

    Joined:
    Dec 25, 2014
    Posts:
    19
    Basically I am eventually making my game multiplayer, so this isn't necessary immediately, but I was wondering how it would work.

    Essentially I want to make a highlight system for units or game objects for when a player is targeting with an ability. However, I am curious as to how the highlight object I create could be spawned in only for the local player?

    The highlights are only visual, so they don't need to be displayed across the network, just locally.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    If it is just visual, I wouldn't make it a networked object at all unless you want other clients or the server to know of its existence (which it sounds like you don't need). I'd have it instantiated only on that local client then. You could trigger its instantiation from the server using a TargetRpc or ClientRpc, or just do it all from that client.
     
  3. Fikule

    Fikule

    Joined:
    Dec 25, 2014
    Posts:
    19
    Ahh right, that seems far more simple than I was expecting. Though now that you mention it I may end up having targeting data shown across the network (as some feedback during other, allied players, turns). Still, that's more likely to involve passing the current targeting data and having each client make their own highlight objects.

    Thank you for the answer :)
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Yeah in that case you could send a Command to the server with just the targeting data, which updates a SyncVar or one of the synclists with that data for the other clients to know about.