How to export the input history of a gama to a txt/excel file

Hi there,

I have a developed a car simulator for a university project, and i want to record the history of the players inputs. When the driver/player is playing, i want to be able to record the moments when he or she presses the brake/acelerator and for how long. Kinda like race telemetry, that would be cool. Do you guys have any ideas or suggestions? i dont have really a clue on how to do this.

Regards

You can use System.IO.StreamWriter to write to a txt file.

For instance, you can start tweaking this code, it prints a line every time a key is pressed.

public class LogFile : MonoBehaviour
{
    System.IO.StreamWriter m_LogFile;

    void Start()
    {
        m_LogFile = new System.IO.StreamWriter(@"Log.txt");
    }

    void Update()
    {
        if (Input.anyKeyDown)
        {
            m_LogFile.WriteLine("Key Down in frame " + Time.frameCount);
            m_LogFile.Flush();
        }
    }
}