Find local user as gameobject

Options
Hi, I need to find the local user and turn it into a transform.

i need to turn this
target = GameObject.FindGameObjectWithTag("Player").transform;
into something like this
target = PhotonView.Find(viewID).transform;
How do i find the local player's photonview to get the viewID?

Thank you!

Comments

  • mrwayne
    Options
    thats depends on what are you trying to do. A hard method to do that is something like this:
    int myID = PhotonNetwork.player.ID;
    GameObject[] players;
    GameObject myPlayer;
    
    void Start () {
    		players = GameObject.FindGameObjectsWithTag("Player");		
    		foreach (GameObject player in players){
    			int playerLoopId = player.GetComponent<PhotonView>().owner.ID;
    			if (playerLoopId == myID){
    				myPlayer = player;
    			}
    		}
    
    		Transform whatAreYouTryingToDo = myPlayer.transform;
    }
    

    maybe you can be more specific about what you want to do with that.