AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
GrabbableTrackFollow.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using UnityEngine;
5 
6 namespace HoloToolkit.Unity.InputModule.Examples.Grabbables
7 {
12 
14  {
15  [Range(1, 10)]
16  public float lagAmount = 5;
17  public float rotationSpeed = 5;
18  private Rigidbody rb;
19 
20  protected override void Start()
21  {
22  base.Start();
23  rb = GetComponent<Rigidbody>();
24  }
25 
26  protected override void AttachToGrabber(BaseGrabber grabber)
27  {
28  base.AttachToGrabber(grabber);
29  rb.useGravity = false;
30  }
31 
32  protected override void DetachFromGrabber(BaseGrabber grabber)
33  {
34  base.DetachFromGrabber(grabber);
35  rb.useGravity = true;
36  }
37 
38  protected override void OnGrabStay()
39  {
40  base.OnGrabStay();
41  //TODO: Time.time should not be in here. this means that the amount of lag would be dependent on the amount of time spent in the level...
42  transform.position = Vector3.Lerp(transform.position, GrabberPrimary.GrabHandle.position, Time.time / (lagAmount * 1000));
43  }
44  }
45 }
Intended usage: scripts that inherit from this can be attached to the controller, or any object with ...
Definition: BaseGrabber.cs:18
//Intended Usage// Attach a "grabbable_x" script (a script that inherits from this) to any object tha...
This type of grab makes the grabbed object track the position of the grabber The follow can be tight ...
override void OnGrabStay()
Called every frame while StayGrab is active