Search Unity

Which Player Object is My Player Object?

Discussion in 'Multiplayer' started by Tinjaw, Nov 9, 2015.

  1. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    If I have a turtle prefab that is marked as the player prefab and auto spawned, then when three clients connect to the host, every client will have three four instances (don't forget the host's local client) of the turtle. If in the scene there is another GameObject, and you want to get a reference to your own clone of the turtle, how do you do that?

    You can use GameObject. FindObjectsOfType<turtle>(), but you will get back four. How do you narrow them down to which one is yours?

    Does that make sense? Did I explain that well enough?

    ===UPDATE===

    For anybody also looking for answer, I just discovered IsLocalPlayer. That is what I needed.
     
    Last edited: Nov 9, 2015