AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
BaseThrowable.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  public abstract class BaseThrowable : MonoBehaviour
13  {
14  public float ThrowMultiplier { get { return throwMultiplier; } set { throwMultiplier = value; } }
15 
16  public bool ZeroGravityThrow { get { return zeroGravityThrow; } set { zeroGravityThrow = value; } }
17 
18  public bool Thrown { get { return thrown; } set { thrown = value; } }
19 
20  // To get velocity info straight from controller
21  public Vector3 LatestControllerThrowVelocity { get; set; }
22  public Vector3 LatestControllerThrowAngularVelocity { get; set; }
23 
24  // TODO: Not implemented yet. lower priority
25  public AnimationCurve VelocityOverTime { get { return velocityOverTime; } set { velocityOverTime = value; } }
26 
27  public AnimationCurve UpDownCurveOverTime { get { return upDownCurveOverTime; } set { upDownCurveOverTime = value; } }
28 
29  public AnimationCurve LeftRightCurveOverTime { get { return leftRightCurveOverTime; } set { leftRightCurveOverTime = value; } }
30 
31  private BaseGrabbable grabbable;
32 
33  [SerializeField]
34  private float throwMultiplier = 1.0f;
35 
36  [SerializeField]
37  private bool zeroGravityThrow;
38 
39  [SerializeField]
40  private AnimationCurve velocityOverTime;
41 
42  [SerializeField]
43  private AnimationCurve upDownCurveOverTime;
44 
45  [SerializeField]
46  private AnimationCurve leftRightCurveOverTime;
47 
48  private bool thrown;
49 
50  protected virtual void Awake()
51  {
52  grabbable = GetComponent<BaseGrabbable>();
53  }
54 
58  protected virtual void OnEnable()
59  {
60  grabbable.OnReleased += Throw;
61  }
62 
63  protected virtual void OnDisable()
64  {
65  grabbable.OnReleased -= Throw;
66  }
67 
68  protected virtual void BeginThrow()
69  {
70  Debug.Log("Begin throw detected.");
71  }
72 
73  protected virtual void MidThrow()
74  {
75  Debug.Log("mid throw...");
76  }
77 
78  protected virtual void ReleaseThrow()
79  {
80  Debug.Log("Throw release...");
81  }
82 
83  protected virtual void OnThrowCanceled()
84  {
85  Debug.Log("Throw canceled");
86  }
87 
92  public virtual void Throw(BaseGrabbable grabber)
93  {
94  Debug.Log("Throwing..");
95  thrown = true;
96  }
97  }
98 }
The abstract class that defines the minimum amount of content for any throwable object Variables decl...
virtual void Throw(BaseGrabbable grabber)
Throw behavior should be overridden in a non-abstract class
//Intended Usage// Attach a "grabbable_x" script (a script that inherits from this) to any object tha...
virtual void OnEnable()
throw needs to subscribe to grab events to know when to apply the appropriate force to an object ...