Game stops when i hit a note
I'm making a rhythm game and when I go to hit a note it crashes and says that I hit and missed the note. not sure what is wrong but if someone could help id appreciate it.
Here is my code:
using System.Collections; using System.Collections.Generic; using System.Diagnostics; using UnityEngine; using UnityEngine.UI;
public class GameManager : MonoBehaviour { public AudioSource theMusic;
public bool startPlaying;
public BeatScroller theBS;
public static GameManager instance;
public int currentScore;
public int scorePerNote = 100;
public Text scoreText; public Text multiText;
// Start is called before the first frame update
void Start()
{
instance = this;
}
// Update is called once per frame
void Update()
{
if(!startPlaying)
{
if(Input.anyKeyDown)
{
startPlaying = true;
theBS.hasStarted = true;
theMusic.Play();
}
}
}
public void NoteHit() { UnityEngine.Debug.Log("Hit on Time");
currentScore += scorePerNote;
scoreText.text = "Score: " + currentScore;
}
public void NoteMissed()
{
UnityEngine.Debug.Log("Missed Note");
}
} ,I'm making a rhythm game for a project but when I hit a note the score should go up but instead, it just stops the whole game and say I both it and missed the note. I would appreciate it if someone could explain why this is happening.
Here is my code:
using System.Collections; using System.Collections.Generic; using System.Diagnostics; using UnityEngine; using UnityEngine.UI;
public class GameManager : MonoBehaviour { public AudioSource theMusic;
public bool startPlaying;
public BeatScroller theBS;
public static GameManager instance;
public int currentScore;
public int scorePerNote = 100;
public Text scoreText; public Text multiText;
// Start is called before the first frame update
void Start()
{
instance = this;
}
// Update is called once per frame
void Update()
{
if(!startPlaying)
{
if(Input.anyKeyDown)
{
startPlaying = true;
theBS.hasStarted = true;
theMusic.Play();
}
}
}
public void NoteHit() { UnityEngine.Debug.Log("Hit on Time");
currentScore += scorePerNote;
scoreText.text = "Score: " + currentScore;
}
public void NoteMissed()
{
UnityEngine.Debug.Log("Missed Note");
}
}
Your answer
Follow this Question
Related Questions
hitbox too big? 0 Answers
HitBox scale in 2 points 0 Answers
Boxcollider not dealing damage unless moving | Unity2D 1 Answer
How to detect if a trigger box has entered an object? 1 Answer
Determine collision points/area 0 Answers