1 using System.Collections;
2 using System.Collections.Generic;
15 private float distance_travelled_since_grab = 0f;
16 private float normalization_distance = 0.5f;
22 return virtualGrabPoint.position;
26 return virtualGrabPoint.rotation;
30 return virtualGrabPoint;
36 virtualGrabPoint =
new GameObject(
"virtualGrabPoint").transform;
37 virtualGrabPoint.SetParent(base.getTargetTransform());
38 virtualGrabPoint.localRotation = Quaternion.identity;
39 virtualGrabPoint.localPosition = Vector3.zero;
44 base.makeGrab(location);
45 if (grabbedObject != null)
47 if(grabbedObject.objectType.handToObject) {
48 if(handVisual!=null) handVisual.glove_transform.position += grabLocation.location - grabPoint.position;
50 virtualGrabPoint.position = grabbedObject.transform.position;
51 virtualGrabPoint.rotation = grabbedObject.transform.rotation;
55 pos_offset = virtualGrabPoint.localPosition;
56 rot_offset = virtualGrabPoint.localRotation;
58 distance_travelled_since_grab = 0f;
65 if(handVisual) handVisual.glove_transform.localPosition = Vector3.zero;
66 virtualGrabPoint.localPosition = Vector3.zero;
67 virtualGrabPoint.localRotation = Quaternion.identity;
68 pos_offset = Vector3.zero;
69 rot_offset = Quaternion.identity;
74 if (IsOnline && !IsOwner)
return;
78 if(grabbedObject!=null) {
79 float factor = distance_travelled_since_grab / normalization_distance;
81 virtualGrabPoint.localPosition = Vector3.Lerp(pos_offset, Vector3.zero, factor);
82 virtualGrabPoint.localRotation = Quaternion.Lerp(rot_offset, Quaternion.identity, factor);
84 distance_travelled_since_grab +=
85 Vector3.Distance(lastPos, virtualGrabPoint.position) +
90 distance_travelled_since_grab = 0f;
92 lastPos = virtualGrabPoint.position;
97 yield
return StartCoroutine(base.setHand());
102 yield
return StartCoroutine(base.unsetHand());
override Quaternion getTargetRotation()
Target rotation the grabbed object should "strive" towards in world space. There will be force trying...
override Transform getTargetTransform()
getTargetPosition() and getTargetRotation() combined into one transform. The grabbed objects transfor...
Equivalent to AVR_OffsetGrabProvider, but additionally allows for hand-to-object grab mode to be used...
override void makeRelease()
Ends a grab. Is called when the respective "releaseEvent" is true.
override IEnumerator setHand()
Represents an (attempted) grab at a given location of an object.
Transform virtualGrabPoint
Sets the documentation html file inside of Packages/com.avr.core/Documentation/html of a given class...
override Vector3 getTargetPosition()
Target position the grabbed object should "strive" towards in world coordiantes. There will be force ...
override IEnumerator unsetHand()
override void makeGrab(GrabLocation location)
Perform a grab on with parameters given in a GrabLocation struct
Same as BasicGrabProvider but additionally allows grabbing objects at an offset. (Eg. you may grab a pan by its handle instead of just its center) Also allows the usage of an AVR_Hand. Use this if you require grabbing larger / more complex objects.