It should be pretty obvious from the code below what I’m trying to do. I had accomplished something similar in JS but haven’t got it quite figured out in C#
Essentially I am trying to start one coroutine if the object is in the trigger, but if it is not in the trigger it should start the other one.
Any help on this would be appreciated as I’ve been stuck on this one.
using UnityEngine;
using System;
using System.Collections;
public class TriggerWwiseEvent_WepHit : MonoBehaviour {
private float coolDown = 2.4f;
private bool isPlaying = false;
private bool isInTarget = false;
//This coroutine should run if NOT in the trigger//
void Update() {
if (!isPlaying && Input.GetButtonUp("BasicAttack")){
StartCoroutine("PlayPSNO");
}
}
//This coroutine should run it IS in the trigger//
void OnTriggerStay (Collider in_other) {
if (in_other.tag == "Morde_Waist" && !isPlaying && Input.GetButtonUp("BasicAttack")){
StartCoroutine("PlayPS");
}
}
IEnumerator PlayPS() {
isPlaying = true;
yield return new WaitForSeconds(0.6f);
GetComponent<AkTriggerEnterWeapon>().Keypress2();
yield return new WaitForSeconds(coolDown);
isPlaying = false;
}
IEnumerator PlayPSNO() {
isPlaying = true;
yield return new WaitForSeconds(0.6f);
yield return new WaitForSeconds(coolDown);
isPlaying = false;
}
}