Help with multiplayer FPS health
So I have an extremely basic Multiplayer FPS game working using Unity's native networking features. I have a health bar show up at the top of the screen using this:
void OnGUI(){ GUI.Box (new Rect (10, 10, 100, 30), "HP | " + currentHealth); }
The problem with this is when I have one player shoot another, I shows both health bars at once, on over another. How can I have the player only see their health and not the other player's health?
Answer by rajavamsidhar_gvs · Mar 02, 2016 at 09:54 AM
i like to answer mutliplayer questions.
here you should use conditions
just attach networkview component to your object which object has this script, and play now..
void OnGUI(){
if(GetComponent<NetworkView>().isMine){//it will display only your player health
GUI.Box (new Rect (10, 10, 100, 30), "HP | " + currentHealth);
}
}
cool,..just you try it.and say it works or not. because when ever we are trying to make a multiplayer game we should disable our controls in other system. in unity it take care itself by using network component and. is$$anonymous$$ine is a bool value. when you are not a player in other system it hides your control.
Sorry, but I have no idea what you mean by any of that. I did try it and it did not work.