public void OnTriggerEnter(Collider other) { if (isPressing || disabled || keyboard.disabled || !keyboard.initialized) { return; } Mallet mallet = other.gameObject.GetComponent <Mallet> (); if (mallet != null) { if (!mallet.isMovingDownward) { return; } if (mallet.hand == Mallet.MalletHand.Left && keyboard.leftPressing) { return; } else if (mallet.hand == Mallet.MalletHand.Right && keyboard.rightPressing) { return; } if (_Press != null && _Press.MoveNext()) { StopCoroutine(_Press); } _Press = Press(other, mallet); StartCoroutine(_Press); } }
private IEnumerator Press(Collider other, Mallet mallet) { isPressing = true; if (mallet.hand == Mallet.MalletHand.Left) { keyboard.leftPressing = true; } else if (mallet.hand == Mallet.MalletHand.Right) { keyboard.rightPressing = true; } mallet.HandleTriggerEnter(this); HandleTriggerEnter(other); transform.localPosition = pressedPosition; yield return(new WaitForSeconds(0.125f)); transform.localPosition = defaultPosition; isPressing = false; if (mallet.hand == Mallet.MalletHand.Left) { keyboard.leftPressing = false; } else if (mallet.hand == Mallet.MalletHand.Right) { keyboard.rightPressing = false; } }
public override void OnInteractionTrigger(InteractionModes mode) { Collider other = gameObject.GetComponent <Collider>(); Mallet mallet = other.gameObject.GetComponent <Mallet>(); _Press = Press(other, mallet); StartCoroutine(_Press); }
private IEnumerator Press(Collider other, Mallet mallet) { isPressing = true; keyboard.leftPressing = true; HandleTriggerEnter(other); transform.localPosition = pressedPosition; yield return(new WaitForSeconds(0.125f)); transform.localPosition = defaultPosition; isPressing = false; keyboard.leftPressing = false; OnFinish(); }
private void Start() { mallet = GetComponent <Mallet> (); }
private void Start() { mallet = GetComponent <Mallet> (); //controllerCharacteristics = InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.Left | InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller; controllerCharacteristics = (mallet.hand == Mallet.MalletHand.Left) ? InputDeviceCharacteristics.Left | InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.HeldInHand : InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.HeldInHand; }
private void Start() { mallet = GetComponent <Mallet> (); role = (mallet.hand == Mallet.MalletHand.Left) ? InputDeviceRole.LeftHanded : InputDeviceRole.RightHanded; }