- Home /
Change instance local variable through RPC to All and to one
Ok, so i have a prefab called player in a pvp game(player vs player) and i want to change the damaged (int) playerHp variable through rpc like this:
onColissionStay(col: Collision){ if(col.gameObject.tag=="player"){ //damage another player with my atack power damagePlayer(this.atackPower, col.gameObject); } }@rpc function damagePlayer(atackpower: int, another GameObject){ //damage another network player on his Player.js.. but how? is
//realy a gameObject or networkgameobject? how to acess his hp?? }
the other issue is change one int variable SpawnOrder (must be global and same for all users) and belongs to serverScript i will increment it when a client connect... so
OnConnectedToServer(){
SpawnOrder++;//this must increase globaly, so all players connected must inscrease
//its value
spawnplayer(SpawnOrder);
}
Thank you very much!
Your answer
![](https://koobas.hobune.stream/wayback/20220613161749im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
Pairing and GUITexture with a Timer? 1 Answer
Walking sound change 0 Answers
How i make this code in Unity Javascript 2 Answers