Changing a player's variable
Options
On the scene, where players connect, there is a button with the scripts "CheckMoney"
There is also a player with a script "Player" on this scene
The problem is that the Check Money script checks the Money variable only for the last player who entered the game
Question - how to correctly implement a variable check for the player who clicked the button?
I will be grateful for your answers
public Player player; public void CheckMoney() { if(player.money >= 5) player.money -= 5; }
There is also a player with a script "Player" on this scene
public int money; private CheckMoney gb; private void Start() { gb = GameObject.Find("CheckMoneyGB").GetComponent<CheckMoney>(); gb.player = this.gameObject.GetComponent<Player>(); }
The problem is that the Check Money script checks the Money variable only for the last player who entered the game
Question - how to correctly implement a variable check for the player who clicked the button?
I will be grateful for your answers
0
Comments
-
I don't know exactly what you need to implement but this sounds as if you need to use Custom Properties.
This page should help:
https://doc.photonengine.com/en-us/pun/current/gameplay/synchronization-and-state
There is also the PUN Basics Tutorial and I would point out having a look at the Asteroids Demo, too.0