Question by 
               secundino3222 · Jul 11, 2020 at 07:54 PM · 
                c#2d game2d sprites2d-gameplayrhythm  
              
 
              Rhythm game LONG NOTES
Hello im currently making a game similar to guitar hero. I had no idea how to code in C# and so far i followed a tutorial on how to make the game I got regular notes working and even registering if the timing was good or bad. I use a box collider on the notes for that to happen. But I really want to know how to make long notes like the ones in guitar hero. If you guys could help me I would be glad :). As I dont know much about how to really code if you guys could help me with a code example I would be really really glad! Have a nice day.
CODE:
 public class NoteObject : MonoBehaviour
 {
     public bool canBePressed;
 
     public KeyCode keyToPress;
 
 
     public GameObject hitEffect, goodEffect, perfectEffect, missEffect;
     
     // Start is called before the first frame update
     void Start()
     {
         
     }
 
     // Update is called once per frame
     void Update()
     {
         if (Input.GetKeyDown(keyToPress))
         {
             if (canBePressed)
             {
                 gameObject.SetActive(false);
 
                // GameManager.instance.NoteHit();
 
                 if (Mathf.Abs (transform.position.y) > 0.25)
                 {
                     Debug.Log("Hit");
                     GameManager.instance.NormalHit();
                     Instantiate(hitEffect, transform.position, hitEffect.transform.rotation);
                 } else if(Mathf.Abs(transform.position.y) > 0.05f)
                 {
                     Debug.Log("Good!");
                     GameManager.instance.GoodHit();
                     Instantiate(goodEffect, transform.position, goodEffect.transform.rotation);
 
                 }
                 else
                 {
                     Debug.Log("Perfect!");
                     GameManager.instance.PerfectHit();
                     Instantiate(perfectEffect, transform.position, perfectEffect.transform.rotation);
 
                 }
             }
         }
     }
 
     private void OnTriggerEnter2D(Collider2D other)
     {
         if (other.tag== "Activator")
         {
             canBePressed = true;
         }
     }
     private void OnTriggerExit2D(Collider2D other)
     {
 
        if (other.tag == "Activator" && gameObject.activeSelf)
         {
             canBePressed = false;
 
             GameManager.instance.NoteMiss();
             Instantiate(missEffect, transform.position, missEffect.transform.rotation);
 
         }
     }
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Help 2D Custom HillClimbRacingGame 0 Answers
Is it possible to add an Input Counter during Splash Screens? 0 Answers
Factorio-like sprite directions 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                