This script is missing some stuff because i’ve been deleting and changing things so if something isn’t being used just ignore it for now but my question is why are my Debugs not working. The arrow gameobjects are clearly passing through the triggers but nothings happening.
This script is placed on Arrows which then move up through triggers.
using UnityEngine;
using System.Collections;
public class RhythmGameArrows : MonoBehaviour {
public float moveSpeed = 2.5f;
public GameObject thisArrow;
public AudioClip chime;
void Start()
{
thisArrow = this.gameObject;
}
void Update ()
{
transform.Translate(Vector3.up*moveSpeed * Time.deltaTime, Space.World);
StartCoroutine(kill ());
}
void OnTriggerStay(Collider other)
{
if(other.tag == "farLeftCatcher" && thisArrow.tag == "leftArrow")
{
Debug.Log("Hit");
if(Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
{
good ();
}
}
else if(other.tag == "leftCatcher" && thisArrow.tag == "upArrow")
{
Debug.Log("Hit");
if(Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
{
good ();
}
}
else if(other.tag == "farRightCatcher" && thisArrow.tag == "rightArrow")
{
Debug.Log("Hit");
if(Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
{
good ();
}
}
else if(other.tag == "rightCatcher" && thisArrow.tag == "downArrow")
{
Debug.Log("Hit");
if(Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
{
good ();
}
}
}
void good()
{
GetComponent<AudioSource>().PlayOneShot(chime);
PlayerPrefs.SetInt("Cash", PlayerPrefs.GetInt("Cash") + 1);
Destroy(gameObject);
}
private IEnumerator kill()
{
yield return new WaitForSeconds(2);
Destroy(gameObject);
}
}