feat: grabbable ball script to utilize transform parenting - #827
Conversation
| } | ||
|
|
||
| [ClientRpc] | ||
| private void UpdateParentClientRpc(ulong ownerClientId, bool isFree) |
There was a problem hiding this comment.
as discussed, I'd be interested to see the simple case users are used to: transform.parent = otherTransform
There was a problem hiding this comment.
I think that can't be done in NetworkObject or NetworkBehaviour level (here we're doing it on NetworkBehaviour level).
That'd be a built-in feature for NetworkTransform to automagically support transform parenting.
This PR is more or less a "it's achievable with MLAPI" demo :)
There was a problem hiding this comment.
I think the question is, and it's a difficult one, whether it makes sense for MLAPI to replicate the transform hierarchy across the connected clients.
Today, as this very helpful example shows, you get parenting in a fairly expected way by a fairly unexpected mechanism. The source machine has the child receive its parental movement by virtue of it being a child transform of the parent (the mechanism a plain, non-MLAPI Unity user expects). However the destination machine gets its child movement as an absolute position by being replicated via the child's NetworkObject/NetworkTransform. It's like in one case the child is implicitly positioned by the Unity transform parent mechanism, but the other side gets the "output" of that mechanism.
One other way would be to have all connected clients be aware of changes to parented transforms so that their object hierarchies would match up. Then, rather than send the child's absolute position you'd instead actually send nothing and let the same implicit parent/child relationship cause the child to follow the parent when we cause the parent's NetworkObject/NetworkTransform to move. Folks have weighed in with caution on this.
…nity-Technologies/com.unity.multiplayer.mlapi into feature/NetworkTransform-using-Netvars * 'feature/NetworkTransform-using-Netvars' of github.com:Unity-Technologies/com.unity.multiplayer.mlapi: feat: grabbable ball script to utilize transform parenting (#827)
GrabbableBallused to move transform on Update() but with this PR, it will utilize transform parenting.