Its a guitar/rhythm game and I am working on a hold note. A hold note is a long vertical line. When it collides with the button(tag Activator), you have to hold it until it reaches the top end.
Debug.Log “Holding” and “Not Holding Down” works but its not suppose to say “Not Holding down” when you’re holding a key down. Not sure if “!Input.GetKeyDown(keyToPress)” is right or something is missing…
public class NoteHoldObject : MonoBehaviour
{
public bool canBeHolded;
public KeyCode keyToHold;
void Update()
{
if (Input.GetKeyUp(keyToPress))
{
if (canBeHolded)
{
Debug.Log("Holding");
Debug.Log(transform.position);
}
}
}
private void OnTriggerStay(Collider other)
{
if (other.tag == "Activator")
{
canBeHolded = true;
{
if (Mathf.Abs(transform.position.z) <= 10f && !Input.GetKeyDown(keyToPress))
{
Debug.Log("Not Holding Down");
}
}
}
}