- Home /
Question by
Heffalus · Mar 11, 2015 at 05:13 PM ·
c#photonobject reference
PUN player referencing
Im using photon unity networking, and what im need to do is reference my player object from a script on another gameobject. It needs to be my player and not some other users player.
foreach (GameObject go in GameObject.FindGameObjectsWithTag ("Player")) {
if (go.GetComponent<PhotonView>().isMine) {
equipmentScript = GetComponent<EquipmentScript> ();
}
}
I thought this would work but it doesnt, is there any special way to reference MY player?
Comment
Best Answer
Answer by Heffalus · Mar 11, 2015 at 11:18 PM
finally found a solution, here it is if anyone else has use for it
foreach (GameObject go in GameObject.FindGameObjectsWithTag("Player")) {
if(go.GetComponent<PhotonView>().owner == PhotonNetwork.player) {
equipmentScript = go.GetComponent<EquipmentScript>();
}
}
Your answer
Follow this Question
Related Questions
Issues with PhotonView 2 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to change default FirstPersonController walkspeed from other script? 2 Answers