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.
 
 
 

47 lines
1.7 KiB

namespace VRTK.Examples
{
using UnityEngine;
public class RC_Car_Controller : MonoBehaviour
{
public GameObject rcCar;
private RC_Car rcCarScript;
private void Start()
{
rcCarScript = rcCar.GetComponent<RC_Car>();
GetComponent<VRTK_ControllerEvents>().TriggerAxisChanged += new ControllerInteractionEventHandler(DoTriggerAxisChanged);
GetComponent<VRTK_ControllerEvents>().TouchpadAxisChanged += new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
GetComponent<VRTK_ControllerEvents>().TriggerReleased += new ControllerInteractionEventHandler(DoTriggerReleased);
GetComponent<VRTK_ControllerEvents>().TouchpadTouchEnd += new ControllerInteractionEventHandler(DoTouchpadTouchEnd);
GetComponent<VRTK_ControllerEvents>().ButtonTwoPressed += new ControllerInteractionEventHandler(DoCarReset);
}
private void DoTouchpadAxisChanged(object sender, ControllerInteractionEventArgs e)
{
rcCarScript.SetTouchAxis(e.touchpadAxis);
}
private void DoTriggerAxisChanged(object sender, ControllerInteractionEventArgs e)
{
rcCarScript.SetTriggerAxis(e.buttonPressure);
}
private void DoTouchpadTouchEnd(object sender, ControllerInteractionEventArgs e)
{
rcCarScript.SetTouchAxis(Vector2.zero);
}
private void DoTriggerReleased(object sender, ControllerInteractionEventArgs e)
{
rcCarScript.SetTriggerAxis(0f);
}
private void DoCarReset(object sender, ControllerInteractionEventArgs e)
{
rcCarScript.ResetCar();
}
}
}