Hi there,
I have an application set up where I can connect multiple instances over a local network. At the moment I am just moving a box, whilst I figuring out how to get client-side smoothing working.
I have the script from the Unity networking examples, which looks like it is working. The only trouble is that the boxes (that the client doesn’t own) are having their position set to 0,0,0 every frame/update/whatever.
The only time someone else’s box is in the correct place is when it is moving, and even then it flickers between that position and the world origin. The prefab I am spawning has a starting transform position of 0,0,0 and is placed in a specific location by the Network.Instantiate() function when the client connects.
I thought the problem could have something to do with these 2 lines:
if (stream.isWriting)
{
*Vector3 pos = transform.localPosition;* // this one
Quaternion rot = transform.localRotation;
stream.Serialize(ref pos);
stream.Serialize(ref rot);
}
// When receiving, buffer the information
else
{
// Receive latest state information
*Vector3 pos = Vector3.zero;* // and this one
Quaternion rot = Quaternion.identity;
stream.Serialize(ref pos);
stream.Serialize(ref rot);
but neither broadcasting the world position nor initialising the recieving vector differently made any difference, so the reason the box is being set to the origin isn’t that.
When I change the box prefab’s NetworkView component to Unreliable the box flickers regardless of user input.
In my mind I think that the client is, for some reason, resetting the prefab to its original transform position unless it gets sent where to put it.
I find this strange as without the smoothing script, my boxes do not flicker although they do have jerky movement because of lag.
Does anyone have any suggestions? Thanks,
Simon.