- Home /
network GUI not working
I'm trying to make an online fps game but the health bar is giving me the health of whoever I'm shooting at instead of my own player.
Part of my health code
function ApplyDamage (damage : float) { // We already have less than 0 hitpoints, maybe we got killed already? if (hitPoints <= 0.0) return;
hitPoints -= damage;
Healthtext = hitPoints.ToString();
if (hitPoints <= 0.0)
{
Detonate();
}
}
function OnGUI () { if (networkView.isMine) { GUI.skin.font = MyFont; GUI.Label(Rect (135,506,900,900), Healthtext); } }
Can you add the variable declaration of hitPoints and Healthtext? $$anonymous$$y guess is that's declared as static.. but it's just a guess. Also make sure that every player owns his own playerobject (everyone instantiate his own player). Some more information would be nice. If you check the health of all players in the inspector during game, are they set to the right values? $$anonymous$$aybe add some Debug.Log messages to see when, who and on which player ApplyDamage is executed. With that little information i can't figure out any errors right now.
hitpoints is public, healthtext is private. The hitpoints work correctly in game.
Answer by burgunfaust · Apr 24, 2011 at 12:57 PM
Try this out:
GUI.Label(Rect (135,506,900,900), this.Healthtext);
Don't know if it will work, but it might.
Your answer
Follow this Question
Related Questions
networkview + GUI 2 Answers
When online GUI.Label (or text area etc) shows overlapping text 2 Answers
How would you set up a Lobby Scene? 1 Answer
[SyncVar] protect Cheat Engine 0 Answers