7
« on: January 13, 2014, 02:33:07 PM »
EDIT : actually I'm still having some issues !
Hello,
I'm using a Progressebar UISlider object to display health of players, created from prefabs "player" in HUD, everything works fine.
But if I have more than 2 players in the same "room", still everything works okay in term of displays, but recently I discovered 2 issues :
One : if a player leave the game (alt+f4), the UIFollowTarget will throw Transform null reference, because the HUD is still existing and so is the healthbar.
More details : How to handle disconnections of players knowing that i'm currently using this function to remove the HUD Object that was responsible of displaying NGUI stuff of the disconnected player and that I don’t need anymore since the player has left, so the Body of the player is automatically removed while the HUD remains in the UIRoot and keeps sending errors of null reference in the console because UIFollowTarget can’t find its target anymore here is my function :
OnNetworkPlayerLeave(Player p)
{
Debug.Log("Player Disconnected");
tno.Send("OnDeath", Target.All, HUDParent, healthBarRef); //Line 123
}
Line 123 : sending the HUD as a GameObject & HealthBar as a UISlider component just in case I want to use it but this rfc call triggers a error :
So why I can't send a specific GameObject to all other clients so they remove it from their screen.
The way I understood it, it should work, unless it has somthing to do with custom packets.
Or there is a better way to handle this situation.
Basically I want the HUD to disappear with the Prefab player that the player controls when he is connected, and that is magically deleted if he leaves, but the work is not completely done, I want it to delete the HUD too.
I didn't explained it well, but when player B leave the game his HUD remains in the screen including his healthbar with no target to follow just floating around where the player B were lastly before he disconnects.
Two : Sync Problem : if player A is connected, Player B is not connected yet, player A got hit and had his HP droped down to 40%, player B once connected after this has happened will see player A 100% HP, what I'm doing rightnow is using a rfc call each time player A hp are decreasing : tno.Send("HitPlayer", Target.AllSaved, Dmg);
and it applies dmg to the target that should be hit, in screen A I can see the real value say 35% of the UISlider.value, but in Screen B the player that connected in “delay” I see that it has 100% hp
How to sync healthbar values that are GameObjects inside of UIRoot using HUDText asset which have on them UIFollowTarget & UISlider, I'm sending RFC(S), each time the healthbar value decreases to Target.AllSaved what am I doing wrong ?
Just some guide lines, I'm still learning about TNet all I have is a basic idea of how Networking works.
Best wishes and thanks for your time.