Hey Folks, I have the following situation and could use some help:
I have a ClientNetworkTransform that will be parented to different objects via ServerRPC and should transmit the position In Local Space. When changing parents the global position should stay the same. So that’s why I am always calculating and setting the position relative to the current parent and use Teleport to set it to the ClientNetworkTransform.
On the client everything seems to work fine, however on the Server the object is jumping away for a couple of frames as soon as I change the parent.
So here is what I’ve observed happening with changing between parent object or no parent object: The problem appears to be as followed: I am pressing the button to change the parent from none to the parent object. The client is sending the serverRPC. However the client also still sends the current position without relation to the new parent (since it has only sent the RPC but the server didn’t execute the parenting yet). So the server receives the RPC to parent the ClientNetworkTransform to the parentobject, but also receives a position from the client that was calculated without parent(in global) that is now applied to the localPosition with the newly set parent. Thats where the target objects position gets out of sync because the server is taking the global position but uses it as a local. It takes a couple of frames untill the new parent is now also set on the client and the local positions are now in sync on client and server and in relation to the same object.
Now my question is, is there any way to make the client change the parent directly (without server RPC)? (I believe there is not but please let me know if there is a workaround)
How else could I resolve this?