VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
override void AVR.Phys.AVR_OffsetGrabProvider.Update ( )
inlineprotectedvirtual

Reimplemented from AVR.Phys.AVR_BasicGrabProvider.

Definition at line 78 of file AVR_OffsetGrabProvider.cs.

78  {
79 #if AVR_NET
80  if (IsOnline && !IsOwner) return;
81 #endif
82  // Pre-grab hand
83  if (grabbedObject == null && handVisual != null && grabbableFinder.getGrabLocation(out GrabLocation grabLocation) && !grabLocation.isNode)
84  {
85  handVisual.SqueezeOn(grabLocation.collider, grabPoint.position - grabLocation.location);
86 
87  // This is a hacky/bad way of calculating the "entry-distance" (maximum distance inside the grabzone-collider in direction grabzone_p)
88  Vector3 far_away = 100.0f * (grabLocation.location - grabPoint.position);
89  Vector3 smth = grabbableFinder.closestPoint(far_away);
90  float entrydist = Vector3.Distance(smth, grabPoint.position);
91  float currentdist = Vector3.Distance(grabPoint.position, grabLocation.location);
92 
93  float max_pregrab_adapt_factor = 0.35f; // maximum AdaptWeigth used for pregrab. (weight when grabPoint=p)
94  float max_pregrab_grace_dist = 0.03f; // Distance at which we consider "grabPoint=p" for purposes stated above
95  float w = Mathf.Max(0, max_pregrab_adapt_factor - (Mathf.Max(0, currentdist - max_pregrab_grace_dist) / entrydist));
96 
97  handVisual.SetSqueezeWeight(w);
98 
99  }
100  else if (grabbedObject == null && handVisual)
101  {
102  handVisual.Relax();
103  }
104 
105  // Regular update
106  base.Update();
107  }
AVR_GrabbableFinder grabbableFinder
Area from which the player may grab an object. Required for the grabprovider to work.
abstract bool getGrabLocation(out GrabLocation location)
AVR_Grabbable grabbedObject
Object that is currently being grabbed. Null if no object is being grabbed