Search Unity

get NetworkServer.Spawn spawned object

Discussion in 'Multiplayer' started by Lelon, Jul 11, 2015.

  1. Lelon

    Lelon

    Joined:
    May 24, 2015
    Posts:
    79
    Hi,
    I just started using Unet, and I'm having a problem I dont know what would be the best approach to solve it.
    I have a pet prefab, I spawn the pet using NetworkServer.Spawn, with the [command] tag, and it spawns the pet on the host and the clients, no problems so far.
    Now let's say I want client A to spawn the pet, and the pet has a component that should be disabled only on client A like a health bar for example. How can I have access to the pet gameobject and do changes but only on client A?
     
  2. darkmask58

    darkmask58

    Joined:
    May 9, 2015
    Posts:
    25
    Don't you need some reference for the pet to know who is his owner?
     
  3. Lelon

    Lelon

    Joined:
    May 24, 2015
    Posts:
    79
    Yes, that's what I need, I'm trying to create a OnStartClient override script on the pet, so that once the pet is spawned, I somehow get the owner network id, and see if his is the local player. Any help on how to do so by script?
    I'm kinda confused on how to grab the owner id.

    Edit: I think I solved the problem, I did what I described above, and it worked.
     
    Last edited: Jul 11, 2015
    darkmask58 likes this.