Hello,
I make my first networking game, and I have an isue with the syncvar attribute, I Think I miss one think.
I have my variable here
[SyncVar(hook="OnObjectiveChange")]
private int m_nObjectiveId;
I modify it here (Only server modify the value)
public void SetObjective( int nObjective )
{
if( isServer )
{
m_nObjectiveId = nObjective;
}
}
On my client I go inside my hooked function
private void OnObjectiveChange( int nObjectivId )
{
// Do stuff Change Hud
Debug.Log( "Test Hook on client, new objective : " + nObjectiveId );
...
}
I have on my client console
But on my element :
For informations, my element is a Registered Spawnable element, I use it to share gameplay information between my clients.
I could fix it by assigning my variable in the hooked function, but it’s not the good way, So if someone could explain me what wrong, it would be very nice.
Thanks!