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.
 
 
 

43 lines
1.0 KiB

namespace VRTK.Examples
{
using UnityEngine;
public class RealGun_SafetySwitch : VRTK_InteractableObject
{
public bool safetyOff = true;
private float offAngle = 40f;
private Vector3 fixedPosition;
public override void StartUsing(VRTK_InteractUse currentUsingObject)
{
base.StartUsing(currentUsingObject);
SetSafety(!safetyOff);
}
protected void Start()
{
fixedPosition = transform.localPosition;
SetSafety(safetyOff);
}
protected override void Update()
{
base.Update();
transform.localPosition = fixedPosition;
if (safetyOff)
{
transform.localEulerAngles = new Vector3(0f, 0f, 0f);
}
else
{
transform.localEulerAngles = new Vector3(0f, offAngle, 0f);
}
}
private void SetSafety(bool safety)
{
safetyOff = safety;
}
}
}