Dynamic Commands, Where do I start looking?

So currently, I have a game object(AI) that, when it collides with another game object(bot) with a certain tag, allows the player to control that bot. When the “push” key is pressed and released, the AI is launched at a 45 degree angle, allowing the player to push his way into controlling another bot.

This is a pretty decent core mechanic on its own, and I like it, but I’m trying to push my limits.

What I want to do next is to have a “loop” key that, when held(for a set period of time to avoid memory congestion and too much player fuggery) writes the inputs into a series of commands that the bot does over and over again.

To be honest, I’m not entirely sure where to look, and I’m going to go ahead and swallow my pride(mmm…tastes like progress) and ask for help before I go down anrabbit hole, and end up burnt out with another half finished product that I don’t want to release because of my accursed hybris.

If any of you wise men and women have any suggestions on what could work, what should work, and what absolutely will not work and I should avoid, you would have my gratitude.

you could make a replay system with a record and play function.

lets say you have a List> commands
each byte represent a different input

here is some pseudo code to guide you
i made something similar to record the transform of some cars in order to replay the last second of the race in a slow mo

bool recording = false;
List<List<byte>> commands;

public IEnumerator record()
{
	recording = true;
	
	//init commands
	
	while(recording)
	{
		yield return new WaitForEndOfFrame();
		
		if(Input.(the recording input) is false)
		{
			
			recording = false;
			
		}
		else
		{
			
			//init second dimension array
			
			for(every input you have to check)
			{
				//for each of these input that are pressed, add to the list its byte id
				
			}
			
		}
		
		
	}
}

bool replaying = false;
public IEnumerator replay()
{
	replaying = true;
	for(int i = 0; i < commands.count; i++)
	{
		for(int j = 0; j < commands*.count; j++)*
  •  {*
    

_ //call the function needed for each input in commands in a switch statement_

* yield return null;*

* }*

* }*
* replaying = false;*
}

with that you should be able to make your way