I’m making a fighting game, and I am trying to keep a queue of moves input by the player. For some reason, I am unable to add my strings to the queue.
moverecorder.Enqueue(instructions);
“instructions” is a three-character string. whenever this runs, I get the error:
NullReferenceException: Object reference not set to an instance of an
object
I’ve tried replacing ‘instructions’ with a string, but the error persists.
How do I Enqueue a string?
If you have a look at the definition for Queue.Enqueue you will see that the value passed to the queue can be null. So your error is not comming from the argument that you’re passing.
Probably your
moverecorderis null.