Skip to main content
New Participant
June 11, 2025
Solved

How to snap object in multiplayer Unity Netcode?

  • June 11, 2025
  • 1 reply
  • 330 views

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 ?

    This topic has been closed for replies.
    Best answer by giorgosganias

    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

    New Participant
    June 11, 2025

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