Hello everyone.
Its the first time i use this function and i have a little problem with it.
i want to display the health/maxhealth if the player aims at another player.
At the moment if there is only 1 client connected to the server all runs well but if a second client is connected all players have the health/maxhealth from the server displayed.
function OnSerializeNetworkView(stream : BitStream, info : NetworkMessageInfo)
{
health = PlayerPrefs.GetInt("Health");
maxhealth = PlayerPrefs.GetInt("Max Health");
if (stream.isWriting)
{
stream.Serialize(health);
stream.Serialize(maxhealth);
}
else
{
stream.Serialize(health);
stream.Serialize(maxhealth);
}
}
And this is are the lines to change the value for the display
healthText = hit.transform.GetComponent(PlayerLocalVars).health;
maxhealthText = hit.transform.GetComponent(PlayerLocalVars).maxhealth;
Some info:
The script “PlayerLocalVars” is attached to the player.
The script “PlayerLocalVars” got the Network View component.
The server is a player aswell.