networkview + GUI

I got a problem with my multiplayer FPS:

The LIFE of each character must be shown to each player.

My problem is that both LIFE variables are showed to each player, then for exemple: If player1 is life=100 and player2 is life=5, what is showed to each player is "LIFE 100" + "LIFE 5", one over another, then it looks like 500 or something like...

I must show each 'life' variable to each player...i think i must use networkview commands but I have no idea how...Can you help me?

parts of my code:

var life=100;
[...start and update functions here...]
function ApplyDamage(damage:int) {
    if (life<=0) {
    }else {
    function OnGUI() {
    GUI.Label(Rect(100,100,100,100),"LIFE "+life);

Sorry...I've Solved!

if (networkView.isMine) {
GUI.Label(Rect(100,100,100,100),"LIFE "+life);


Just as an FYI, instead of having to pepper all your scripts randomly with network conditions like "Network.IsServer", "Network.IsClient", and "networkView.IsMine", its useful to do a "network initialization" script for any objects that will be Network.Instantiated.

For example, in your case, you might use a script called "PlayerNetworkInit" that did something like this (for the sake of argument, I'm assuming the name of this health script is PlayerHealth):


function OnNetworkInstantiate(info : NetworkMessageInfo){
        GetComponent(FPSWalker).enabled = false;
        GetComponent(PlayerHealth).enabled = false;

This way, you can manage all the code that you want running on remote instances of this object (instances of this object running on clients that don't own it) from one place.

The beautiful thing about RPC's is you can call an RPC on an object even if the script that contains that RPC function is disabled (so in your case, you can disable the PlayerHealth script on all player objects that the current player doesn't own on the network, so it won't show the GUI code, but you can still send the ApplyDamage RPC message on them).