Page 1 of 1

Save continuous x, y and z positions player in csv or txt file

Posted: Tue Jun 02, 2020 9:35 pm
by thomaythiers
Hello,

I'm a neuroscience student and I need to save the continous x, y and z data from player direction and rotation, as well as key presses, positions of rocks in a river, and other triggers.

Is this possible with easysave ?

How would you use it to do so (especially for the continuous x,y,z positions)

Best,

Thomas

Re: Save continuous x, y and z positions player in csv or txt file

Posted: Wed Jun 03, 2020 6:57 am
by Joel
Hi Thomas,

This is indeed possible. In fact the easiest way to save continuous position to a CSV would be to do the following:

Code: Select all

using UnityEngine;
using System.Collections;

public class SaveContinuous : MonoBehaviour
{
	void FixedUpdate()
	{
		// Create a blank ES3Spreadsheet.
		var sheet = new ES3Spreadsheet();
 
		// Save some values into the spreadsheet.
		sheet.SetCell(0,0, transform.localPosition.x);
		sheet.SetCell(1,0, transform.localPosition.y);
		sheet.SetCell(2,0, transform.localPosition.z);
 
		// Append the row to the existing spreadsheet, or create a new one if it doesn't exist.
		sheet.Save("myData.csv", true);
	}
}
You could also add additional columns to the spreadsheet if necessary representing your other data.

All the best,
Joel

Re: Save continuous x, y and z positions player in csv or txt file

Posted: Wed Jun 03, 2020 3:51 pm
by thomaythiers
Hi Joel,

Thank you so much this is super helpful !!!

Best,

Thomas