Author Topic: Player data usage...confused..  (Read 6121 times)

chiblue

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 21
    • View Profile
Player data usage...confused..
« on: September 05, 2013, 10:57:33 AM »
I have several data elements that I want to store against the player,  so I have created a class and then move this in and out of the player.data object.  My belief was that this data is maintained dynamically,  but it appears that this data never changes and cannot be synchronized between clients...

Example,  part of the class has a gamestatus,  this represents the players ingame statua... i.e. playing, dead, paused etc... I updated the class gamestatus in the player owner object data,  but the other clients only ever see this player.data as null...  Am I doing something wrong or is this player.data static data?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Player data usage...confused..
« Reply #1 on: September 05, 2013, 05:47:09 PM »
Player data is not sync'd -- it's a local value only. You can use it to store a reference to the player's avatar for example. If you want some data associated with the player, you should use RFCs for that instead.

chiblue

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 21
    • View Profile
Re: Player data usage...confused..
« Reply #2 on: September 05, 2013, 06:54:29 PM »
That was what I thought was the case,  I tried using tno.send but it is limited on sending/receiving the data structures that I am trying to use...  I was doing this instead of sending lots of parameters.... I get a runtime error when I try to send a structure or class definition...

I send works fine for a client joining on already connected clients (for the clients already connected),  but the client that joined does not get all the configurations of the other clients.  What I am trying to get is when a client joins is to send a request and have all the connected clients send their configuration,  i.e. weapon, position, etc... 

Doing this as a multiple sends will result in a lot of traffic,  I tried to use a request and response with a list containing the weapons but the send fails...  I tried a customer class and again failed...

how would you recommend I accomplish this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Player data usage...confused..
« Reply #3 on: September 05, 2013, 07:57:33 PM »
Assuming each player gets their own avatar, store this information on a script attached to that avatar. Send this RFC as "Saved", and other players will get the data as well. You only need to send the data when it changes.

chiblue

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 21
    • View Profile
Re: Player data usage...confused..
« Reply #4 on: September 05, 2013, 08:22:01 PM »
Each player gets an instance of an actor class and a networkplayer class that is a prefab....  the actor class contains all the variables needed and exists for both the local and remote game object on each client...  so I believe my actor class is exactly what you are suggesting I use,  but I am sorry but I am not sure what you mean by Send this RFC as "saved"??

Would this be the target.allsaved or target.othersaved??

This will allow me to send the entire class?? or the game object?

I tried

tno.Send("RSendPlayer",Target.OthersSaved,TNManager.playerID, this.gameObject as object);

and

tno.Send("RSendPlayer",Target.OthersSaved,TNManager.playerID, this.gameObject);

Both return the same runtime error...

Unable to write type UnityEngine.GameObject
UnityEngine.Debug:LogError(Object)
TNet.UnityTools:Write(BinaryWriter, Object[]) (at Assets/TNet/Client/TNUnityTools.cs:283)
TNObject:SendRFC(UInt32, Byte, String, Target, Boolean, Object[]) (at Assets/TNet/Client/TNObject.cs:547)
« Last Edit: September 05, 2013, 08:50:25 PM by chiblue »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Player data usage...confused..
« Reply #5 on: September 05, 2013, 09:19:42 PM »
Target.AllSaved. Don't send the game object. Send the values you want saved.

Instead of setting values on a script, send them, and set them inside the function you're sending.

chiblue

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 21
    • View Profile
Re: Player data usage...confused..
« Reply #6 on: September 05, 2013, 09:31:28 PM »
I see,  so allsaved will send it to itself and so update the actor class values in the RFC function,  great idea,  will try it...

Thanks again..