Hello !
I want to write every data at each frame :
void FixedUpdate() {
if (frame < nv_data [0].positions.Length) {
for (int k = 0; k < body.Length; ++k) {
if (body [k] != null) {
body[k].transform.localPosition = nv_data[k].positions [frame] / 1000;
} else
continue;
}
if (frame < forces_dup.Length) {
if (frame > 1) {
StreamWriter writer = new StreamWriter ("1_forces_reelles_virtuelles.txt");
using (writer) {
writer.WriteLine ((40 * nv_data [55].positions [frame] - nv_data [55].positions [frame - 1]).magnitude / (1000 * Time.deltaTime));
writer.WriteLine (forces_dup [frame].magnitude / 1000);
}
}
}
frame++;
}
}
And in the text file, it appears only the last datas of :
- (40 * nv_data [55].positions [frame] - nv_data [55].positions [frame - 1]).magnitude / (1000 * Time.deltaTime)
- forces_dup [frame].magnitude / 1000
When I use "Debug.Log" to show datas, all appear in the console.
I assume that the other lines are erased at each frame.
How can I save every line of datas ?
I try to do it in void Update (but it's the same result) :
void Update() {
string forces_virtuelles;
string forces_reelles;
if (frame < forces_dup.Length) {
if (frame > 1) {
forces_virtuelles = ((40 * nv_data [55].positions [frame] - nv_data [55].positions [frame - 1]).magnitude / (1000 * Time.deltaTime)).ToString();
forces_reelles = (forces_dup[frame].magnitude/1000).ToString();
StreamWriter writer = new StreamWriter ("1_forces_reelles_virtuelles.txt");
using (writer) {
writer.WriteLine (forces_virtuelles + "\n");
writer.WriteLine (forces_reelles + "\n");
}
}
}
}
The first part runs well, even with the second part :
void FixedUpdate() {
if (frame < nv_data [0].positions.Length) {
for (int k = 0; k < body.Length; ++k) {
if (body [k] != null) {
body[k].transform.localPosition = nv_data[k].positions [frame] / 1000;
} else
continue;
}
}
frame++;
}
}
Can you help me please ?