Hello everyone. I’m a new Unity user.
I wondered if I can save the 2D path (coordinates x,y,z) of the main camera, each second.
I’m a really beginner, so I don’t have enough script knowledge.
Thanks in advance
Hello everyone. I’m a new Unity user.
I wondered if I can save the 2D path (coordinates x,y,z) of the main camera, each second.
I’m a really beginner, so I don’t have enough script knowledge.
Thanks in advance
I’m assuming you want to save the 3D path, since you say you want the x, y, z coordinates?
Anyway, in c# you would do something like this:
// the camera you want to monitor
public Camera cam;
// a list to keep the coordinates in
List<Vector3> coordinateHistory = new List<Vector3>();
void Start(){
InvokeRepeating("SaveCoordinates", 0, 1);
}
void SaveCoordinates(){
coordinateHistory.Add(cam.transform.position);
}
I’m not sure how long this will work before your array of coordinates starts to take up too much space - you may need to look into writing the array to a file every so often to prevent running out of memory.