- Home /
Unity 5.2 SyncVar hook only gets called on host. VS debugger dosent debug it fully.
Basically i have a script that edits the location of a box, this box updates from host to client so they both see the box move, but on client to host it has no effect, on debuging the SyncVar Hook i made never calles the function, here is how its setup..
class ObjectUpdatePossition, is attached to the object that im trying to move.
public class ObjectUpdatePossition : NetworkBehaviour
{
[SyncVar(hook = "value_changed")]
private Vector3 syncpos;
[SerializeField]
float lerpRate = 15;
// Update is called once per frame
void value_changed(Vector3 value)
{
this.transform.position = value;
}
[Command]
void CmdProvidePossitionToServer(Vector3 pos)
{
syncpos = pos;
}
[ClientCallback]
public void TransmitPossition(Vector3 val)
{
CmdProvidePossitionToServer(val);
}
}
And then TransmitPossition is called from another class not attached to the object..
ObjectUpdatePossition xthis = //then the refrance to the object that has the ObjectUpdatePossition script attached to it.
xthis.TransmitPossition(Vector3);
Im not entirly sure why the hook is not being called and thus dose not move the box, the TransmitPossition function works fine though and is called no probs..
It maybe that the VS debuger is not debuging it fully, because no matter which side i try to debug i cant caputre and see if it fires the hook
turns out its just the vs debugger that dosent debug it fully, the syncvar calls the hook when at the host but dosent get called on clients.. still not sure why its got to be something simple.
Damn even when i edit and make sure the [Command] is called on the player object, the client still dose not call it on the server.. is this a bug ??
I mean ive pretty much deter$$anonymous$$ed that the syncvar is not being set, becuase the Command is not being called at all on clients, even when as the documents say to only call Commands on the player object which ive done.