Skip to content

Commit ba10fb9

Browse files
committed
Add smoothing to translation and rotation for HandDraggable script
1 parent 54734f5 commit ba10fb9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Assets/HoloToolkit/Input/Scripts/Interactions/HandDraggable.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ public enum RotationModeEnum
4242

4343
public RotationModeEnum RotationMode = RotationModeEnum.Default;
4444

45+
[Tooltip("Controls the speed at which the object will interpolate toward the desired position")]
46+
[Range(0.01f, 1.0f)]
47+
public float PositionLerpSpeed = 0.2f;
48+
49+
[Tooltip("Controls the speed at which the object will interpolate toward the desired rotation")]
50+
[Range(0.01f, 1.0f)]
51+
public float RotationLerpSpeed = 0.2f;
52+
4553
public bool IsDraggingEnabled = true;
4654

4755
private Camera mainCamera;
@@ -214,9 +222,10 @@ private void UpdateDragging()
214222
}
215223

216224
// Apply Final Position
217-
HostTransform.position = draggingPosition + mainCamera.transform.TransformDirection(objRefGrabPoint);
225+
HostTransform.position = Vector3.Lerp(HostTransform.position, draggingPosition + mainCamera.transform.TransformDirection(objRefGrabPoint), PositionLerpSpeed);
218226
// Apply Final Rotation
219-
HostTransform.rotation = draggingRotation;
227+
HostTransform.rotation = Quaternion.Lerp(HostTransform.rotation, draggingRotation, RotationLerpSpeed);
228+
220229
if (RotationMode == RotationModeEnum.OrientTowardUserAndKeepUpright)
221230
{
222231
Quaternion upRotation = Quaternion.FromToRotation(HostTransform.up, Vector3.up);

0 commit comments

Comments
 (0)