Closed
Description
### Issue:
There is no reference to a ClientNetworkVariable to obtain a value from its value property, or any mention of it in the "Debug.Log" statements, yet the output of the test in console says:
"Server's var initialized to: 0
Server set its var to: 0.1, has client var at: 0
Server set its var to: 3.099999, has client var at: 2.6
Server set its var to: 6.099997, has client var at: 5.599997"
### Current Code:
using Unity.Netcode;
using UnityEngine;
public class NetworkVariableTest : NetworkBehaviour
{
private NetworkVariable<float> ServerNetworkVariable = new NetworkVariable<float>();
private float last_t = 0.0f;
public override void OnNetworkSpawn()
{
if (IsServer)
{
ServerNetworkVariable.Value = 0.0f;
Debug.Log("Server's var initialized to: " + ServerNetworkVariable.Value);
}
}
void Update()
{
var t_now = Time.time;
if (IsServer)
{
ServerNetworkVariable.Value = ServerNetworkVariable.Value + 0.1f;
if (t_now - last_t > 0.5f)
{
last_t = t_now;
Debug.Log("Server set its var to: " + ServerNetworkVariable.Value);
}
}
}
}
Metadata
Metadata
Assignees
Labels
No labels