retrieve a special user information
I am trying to make car racing game using photon,when two cars come side by side, i want to ask, I want both players to send some values to each other, for example(their name, their cup, etc)
is it possible?
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
Debug.Log("Player name " + gameObject.GetComponent().owner.NickName);
Debug.Log("Yeni player name " + PhotonNetwork.playerName);
}
}
is it possible?
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
Debug.Log("Player name " + gameObject.GetComponent().owner.NickName);
Debug.Log("Yeni player name " + PhotonNetwork.playerName);
}
}
0
Best Answer
-
Hi @Ygunes,
you can use the Custom Player Properties to store some player related data. These data gets automatically synchronized. The NickName for example is stored in the Custom Player Properties by design.
If you have this, you can use the OnTriggerEnter function you have mentioned above. Then you access the game object's PhotonView component. Having this component you can furthermore access the Owner and his Custom Player Properties. This can be done by usingpView.Owner.CustomProperties
. When you have gathered the necessary data, you can display it the way you want.5
Answers
-
Hi @Ygunes,
you can use the Custom Player Properties to store some player related data. These data gets automatically synchronized. The NickName for example is stored in the Custom Player Properties by design.
If you have this, you can use the OnTriggerEnter function you have mentioned above. Then you access the game object's PhotonView component. Having this component you can furthermore access the Owner and his Custom Player Properties. This can be done by usingpView.Owner.CustomProperties
. When you have gathered the necessary data, you can display it the way you want.5