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.
 
 
 

27 lines
711 B

namespace VRTK.Examples
{
using UnityEngine;
public class Lamp : VRTK_InteractableObject
{
public override void Grabbed(VRTK_InteractGrab grabbingObject)
{
base.Grabbed(grabbingObject);
ToggleKinematics(false);
}
public override void Ungrabbed(VRTK_InteractGrab previousGrabbingObject)
{
base.Ungrabbed(previousGrabbingObject);
ToggleKinematics(true);
}
private void ToggleKinematics(bool state)
{
foreach (Rigidbody rigid in transform.parent.GetComponentsInChildren<Rigidbody>())
{
rigid.isKinematic = state;
}
}
}
}