VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
void AVR.Phys.AVR_Grabbable.Grab ( AVR_BasicGrabProvider  hand)
inline

Definition at line 104 of file AVR_Grabbable.cs.

105  {
106  #if AVR_NET
107  // If we are online and this object is not owned by the grabbing player or the server -> dont allow grab.
108  if(IsOnline && !IsOwnedByServer && !IsOwner)
109  {
110  return;
111  }
112  #endif
113 
114  if(!isGrabbed) {
115  old_parent = this.transform.parent;
116  // while its being grabbed, set the rig as its parent, so that when the rig teleport we dont break the grab-joint.
117  transform.SetParent(AVR.Core.AVR_PlayerRig.Instance.transform);
118  }
119  else if(isGrabbed && !_objType.allowTwoHanded) {
120  // flush AttatchedHands.
121  while(AttachedHands.Count>0) AttachedHands[0].makeRelease();
122  }
123  AttachedHands.Add(hand);
124  hand.controller.HapticPulse(0.3f, 0.05f);
125 
126  //Play pickup sound
127  if (source != null && objectType.soundData.pickupSound != null)
128  {
129  source.PlayOneShot(objectType.soundData.pickupSound, objectType.soundData.volumeMultiplier);
130  }
131 
132 #if AVR_NET
133  if (IsOnline)
134  {
135  NetworkObject.ChangeOwnership(this.OwnerClientId);
136  }
137 #endif
138  }
AudioSource source
Optional AudioSource to play sounds from GrabbableObjectType data
bool isGrabbed
True if the object is being grabbed, otherwise false.
List< AVR_BasicGrabProvider > AttachedHands
List of hands that are currently grabbing this object.
GrabbableObjectType objectType
Type that describes the objects behaviour when grabbed.
GrabbableObjectType _objType
GrabbableObjectSoundData soundData