public void RemoteGrip(RemoteAvatar avatar, RemoteAvatar.Hand hand, int clientId) { Assert.IsTrue(clientId != context.clientId); Release(); var body = gameObject.GetComponent <Rigidbody>(); hand.grip = gameObject; body.isKinematic = true; body.detectCollisions = false; gameObject.transform.SetParent(hand.transform, true); remoteAvatar = avatar; remoteHand = hand; holderId = clientId; authorityId = clientId + 1; avatar.CubeAttached(ref hand); }
/* * Detach cube from any player who is holding it (local or remote). */ public void Release() { if (!HasHolder()) { return; } if (localAvatar) { localAvatar.DetachCube(ref localHand); touching.GetComponent <BoxCollider>().isTrigger = true; } if (remoteAvatar) { remoteAvatar.DetachCube(ref remoteHand); } localAvatar = null; localHand = null; remoteHand = null; remoteAvatar = null; holderId = Nobody; }
public bool HeldBy(RemoteAvatar avatar, RemoteAvatar.Hand hand) => remoteAvatar == avatar && remoteHand == hand;