- Home /
On screen scoring in multiplayer
I am working on a project where I will have up to four players at once all on different computers playing over a network. All player scores will be displayed on the top right of the screen. Players earn points by picking up random objects, and throwing them at each other. So the question is this. Does anyone know of an easy way to associate a thrown object with the player who threw it?
i would say give each player a different tag, then for the object, set up a variable that gets set to the players tag on collision. if the object hits the target, increase thh players score. so not exactly this, but something like this
String objectHolder; void OnCollisionEnter(Collision other) { if (other.tag=="Player2"){ objectHolder = "Player2"; } }
void OnTriggerEnter(Collider other) { if (objectHolder == "Player2") { score++; }
Answer by Rebaken-Enterprises · May 14, 2018 at 12:52 AM
NetworkManager.singleton.client.connection.playerControllers [0].gameObject
That's the player that threw it. i.e. It's the player that is currently on the local machine
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
How to create a point/score system based on player performance. 2 Answers
View PvP scores on screen in real-time 1 Answer
How do you hide the Network HUD GUI? 1 Answer