Question by 
               miguelvvplay321 · Aug 07, 2021 at 12:35 AM · 
                erroreditor-scriptingconsole errorsqueue  
              
 
              Error Queue InvalidOperationException: Queue empty
I have tried to make an inputBuffer to improve the playability of my game but when running the dequeue I get this error the game can be run in the editor
InvalidOperationException: Queue empty. System.Collections.Generic.Queue`1[T].Dequeue () (at :0)
This is my code
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine.UI;
 using UnityEngine;
 
 
 
 public class MovimientoHero : MonoBehaviour
 {
     [Header("Jump")]
     public float Jumpforce;
     public SpriteRenderer spriteRenderer;
     [Header("GROUNDED")]
     public LayerMask floor;
 
     private Rigidbody2D Rigidbody2D;
     private BoxCollider2D boxCollider2D;
     private bool Grounded;
     private Queue<KeyCode> inputBuffer;
 
 
 
 
     void Start()
     {
         Rigidbody2D = GetComponent<Rigidbody2D>();
         boxCollider2D = GetComponent<BoxCollider2D>();
         inputBuffer = new Queue<KeyCode>();
 
     }
 
 
     void Update()
     {
 
         Debug.DrawRay(transform.position, Vector3.down * 0.25f, Color.red);
         if (Physics2D.BoxCast(boxCollider2D.bounds.center, boxCollider2D.bounds.size, 0.0f, Vector2.down, 0.02f, floor))
         {
             Grounded = true;
         }
         else
         {
 
             Grounded = false;
         }
 
 
         if (Input.GetKeyDown(KeyCode.W))
         {
             inputBuffer.Enqueue(KeyCode.W);
             Invoke("DequeueMetodh",0.2f);
         }
         if (Grounded)
         {
             if (inputBuffer.Count > 0)
             {
                 if (inputBuffer.Peek() == KeyCode.W)
                 {
                     Rigidbody2D.velocity = new Vector2(Rigidbody2D.velocity.x, Jumpforce);
                     inputBuffer.Dequeue();
                 }
             }
         }
 
     }
     void DequeueMetodh()
     {
         inputBuffer.Dequeue();
     }
     void FixedUpdate()
     {
         if (Input.GetKey("d"))
         {
             Rigidbody2D.velocity = new Vector2(Speed, Rigidbody2D.velocity.y);
             spriteRenderer.flipX = false;
         }
         else if (Input.GetKey("a"))
         {
             Rigidbody2D.velocity = new Vector2(-Speed, Rigidbody2D.velocity.y);
             spriteRenderer.flipX = true;
         }
         else
         {
             Rigidbody2D.velocity = new Vector2(0, Rigidbody2D.velocity.y);
         }
 }
 
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Problem with my script (Gun and Fire rate) 1 Answer
only using GetMouseButtonDown(0) once 0 Answers
PrecompiledAssemblyException error 4 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                