AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
ThrowableObject.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 System.Collections;
5 using UnityEngine;
6 
7 namespace HoloToolkit.Unity.InputModule.Examples.Grabbables
8 {
14  {
15  public override void Throw(BaseGrabbable grabbable)
16  {
17  base.Throw(grabbable);
18  //Vector3 vel = grabbable.GetAverageVelocity();
19  Vector3 vel = LatestControllerThrowVelocity;
20  Vector3 angVel = LatestControllerThrowAngularVelocity;
21  if (GetComponent<GrabbableFixedJoint>() || GetComponent<GrabbableSpringJoint>())
22  {
23  StartCoroutine(ThrowDelay(vel, angVel, grabbable));
24  }
25  else
26  {
27  GetComponent<Rigidbody>().velocity = vel * ThrowMultiplier;
28  GetComponent<Rigidbody>().angularVelocity = angVel;
29  if (ZeroGravityThrow)
30  {
31  grabbable.GetComponent<Rigidbody>().useGravity = false;
32  }
33  }
34  }
35 
36  private IEnumerator ThrowDelay(Vector3 vel, Vector3 angVel, BaseGrabbable grabbable)
37  {
38  yield return null;
39  GetComponent<Rigidbody>().velocity = vel * ThrowMultiplier;
40  GetComponent<Rigidbody>().angularVelocity = angVel;
41  if (ZeroGravityThrow)
42  {
43  grabbable.GetComponent<Rigidbody>().useGravity = false;
44  }
45  }
46  }
47 }
The abstract class that defines the minimum amount of content for any throwable object Variables decl...
Extends its behaviour from BaseThrowable. This is a non-abstract script that can be attached to throw...
//Intended Usage// Attach a "grabbable_x" script (a script that inherits from this) to any object tha...
override void Throw(BaseGrabbable grabbable)
Throw behavior should be overridden in a non-abstract class