Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
711 B

  1. namespace VRTK.Examples
  2. {
  3. using UnityEngine;
  4. public class Lamp : VRTK_InteractableObject
  5. {
  6. public override void Grabbed(VRTK_InteractGrab grabbingObject)
  7. {
  8. base.Grabbed(grabbingObject);
  9. ToggleKinematics(false);
  10. }
  11. public override void Ungrabbed(VRTK_InteractGrab previousGrabbingObject)
  12. {
  13. base.Ungrabbed(previousGrabbingObject);
  14. ToggleKinematics(true);
  15. }
  16. private void ToggleKinematics(bool state)
  17. {
  18. foreach (Rigidbody rigid in transform.parent.GetComponentsInChildren<Rigidbody>())
  19. {
  20. rigid.isKinematic = state;
  21. }
  22. }
  23. }
  24. }