- Home /
Exporting position, angular velocity, and time to a text file
Hi,
I'm trying to export some data from Unity to a simple text file. The main data I'm interested in is position and angular velocity. I've got a attached to a game object that also has a rigid body component.
So far I've been able to gather and export the position and angular velocity by calling InvokeRepeating() in the Start() method with functions like
void RecAngVels()
{
angVels.Add(rb.angularVelocity);
}
So in Start() I'm calling InvokeRepeating("RecAngVels", 0.0f, 0.1f)
to store the angular velocity at regular intervals, and a similar setup exists for position. I just have to hit a button that shows up in the game to stop InvokeRepeating() and export the stored data to their respective files.
I hope what I'm doing is clear so that my problem will be easier to understand. I was also trying to export time data to correspond to the positions and angular velocities. So I made a similar setup to get time data using Time.time, but when I export the data to the file I get a bunch of the following lines System.Collections.Generic.List`1[System.Single] instead of some time data.
Every time I call Time.time I just store it into a float list so I'm sure that I'm storing numbers and I'm not sure why they aren't being written to the file. Am I misunderstanding how Time.time works or is it something else that I'm missing?
Also, I was hoping to have the same amount of data for position and angular velocity but I get more position data than angular velocity data. Is this because I call InvokeRepeating() on my RecPositions() function before calling it on RecAngVels() in the Start() method? Would the solution be to make two separate Start() methods or two separate scripts?
I'm sorry for the really long post, but I'm very new to Unity and I'm just trying to figure this stuff out on my own, so I appreciate any help that anyone can offer. Thanks in advance!