Skip to content

feat: grabbable ball script to utilize transform parenting #827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2021

Conversation

0xFA11
Copy link
Contributor

@0xFA11 0xFA11 commented May 13, 2021

GrabbableBall used to move transform on Update() but with this PR, it will utilize transform parenting.

}

[ClientRpc]
private void UpdateParentClientRpc(ulong ownerClientId, bool isFree)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, I'd be interested to see the simple case users are used to: transform.parent = otherTransform

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

@0xFA11 0xFA11 merged commit edcd5c7 into develop May 13, 2021
@0xFA11 0xFA11 deleted the feat/grabbable-parenting branch May 13, 2021 23:12
SamuelBellomo added a commit that referenced this pull request May 17, 2021
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants