Forum Discussion
grindinggear
6 months agoHonored Guest
How to snap object in multiplayer Unity Netcode?
I'm using SnapInteractor to snap object to another , and how can i use it in multiplayer with netcode ? How to let all clients see that object is snapped to another ? So far the object just move with network transform ? What is the method to call with ClientRpc to let all clients snap object to another ?
I dont think there is an easy solution to this. We did a similar functionallity where each snapInteractor has a networked boolean isOccupied. When a client snaps an object somewhere, this isOccupied becomes true and you can subscribe a method to this state change for all clients to run. e.g. disable all colliders so that no one can grab the grabbable (snapInteractable) anymore.
Probably the method you are searching for is this series of calls:snapInteractor.SetComputeShouldSelectOverride(() => true, true);snapInteractor.SetComputeCandidateOverride(() => snapInteractable, true);snapInteractor.Select();
but you should know you must have ownership and you must somehow find the snapInteractable in order to give it to SetComputeCandidateOverride()
1 Reply
Replies have been turned off for this discussion
- giorgos.ganiasExplorer
I dont think there is an easy solution to this. We did a similar functionallity where each snapInteractor has a networked boolean isOccupied. When a client snaps an object somewhere, this isOccupied becomes true and you can subscribe a method to this state change for all clients to run. e.g. disable all colliders so that no one can grab the grabbable (snapInteractable) anymore.
Probably the method you are searching for is this series of calls:snapInteractor.SetComputeShouldSelectOverride(() => true, true);snapInteractor.SetComputeCandidateOverride(() => snapInteractable, true);snapInteractor.Select();
but you should know you must have ownership and you must somehow find the snapInteractable in order to give it to SetComputeCandidateOverride()
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 6 months ago
- 2 years ago
- 2 years ago