- Home /
UNET: Network Transform with skeleton?
Hi guys,
I'm working on a multiplayer application involving the Kinect. Everything works; however, I need to send the entire skeleton's transforms to the server for syncing across clients. Currently, it would appear that NetworkTransform only sends the transform of the object it is attached to (not child objects).
Is it possible to have the NetworkTransform be applied recursively?
Answer by seanr · Sep 17, 2015 at 02:19 PM
http://forum.unity3d.com/threads/synchronizing-an-entire-skeleton.355636/
Answer by AubryStrawberry · Aug 06, 2015 at 03:18 PM
Well having had at it - the best I've been able to come up with is to do it manually using [SyncVar] for position and rotation of each joint.
Bearing in mind the limitation of 31 sync vars, it probably isn't ideal though it works for my case.
For future reference, see this video for details of the sync var implementation: https://www.youtube.com/watch?v=NLnzlwCRjgc
[SyncVar] Vector3 HipsPos; // HIPS JOINT
[SyncVar] Quaternion HipsRot;
[SerializeField] Transform Hips;
....
void Update()
{
if (isLocalPlayer)
TransmitPos (); // telling others where this is for them to lerp their client-side obj to
else
LerpTransformPositions(); // lerping this non-local player to the position that the real player transmitted
}
void LerpTransformPositions()
{
float rate = Time.deltaTime * lerpRate;
Hips.position = Vector3.Lerp(Hips.position, HipsPos, rate);
Hips.rotation = Quaternion.Slerp (Hips.rotation, HipsRot, rate);
....
}
[Command]
void Cmd_SendPosToServer()
{
HipsPos = Hips.position;
HipsRot = Hips.rotation;
....
}
[ClientCallback]
void TransmitPos()
{
Cmd_SendPosToServer ();
}
Answer by joostbos · Sep 15, 2015 at 04:55 PM
I've been struggling with the same problem and found the NetworkTransformChild script.
I got my skeleton working by adding a NetworkTransformChild component for each joint to the root of the skeleton. It's still a hell of a manual job, and the root object gets littered with 30-something scripts, but it seems to work.
Where do I find the networkTransformChild? I can't find it
It's in Add Component --> Network. But it could be new in 5.2, because I remember being suprised to see it and that was I think after the upgrade to Unity 5.2
Your answer
![](https://koobas.hobune.stream/wayback/20220611234522im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
UNET relay server for Personal Edition? 1 Answer
Network Transform Slow Rotations 0 Answers
Unity child gameobjects spawning with incorrect transforms over network, any ideas? 0 Answers
Rpc is received by client but Cmd is not received by server 2 Answers
How to give a client authority over an object in UNET? 3 Answers