read in position data from .txt
Hey guys. I'm trying to read in a massive amount of x,y,z and radius data from an external output file(s) and then move them forward in time based on their updated positions (also from output file(s)). Also, for each particle position and radius I would like to generate an in game sphere with that radius value and at the correct position. Ideally, these spheres will recreate a simulation of a star off of the smoothed particle data. I'm very inexperienced with C#, so any help would be appreciated.
Answer by KazYamof · Jun 01, 2016 at 10:19 AM
Read file in C#: https://msdn.microsoft.com/en-us/library/db5x7c0d%28v=vs.110%29.aspx
Define your model of data, like: "x;y;z;r" per line in the file, get a line and split it with SplitString(";") and you will get a array string with all strings separeted by ';'. Then access each string by the position and create a new Vector3:
var pos = new Vector3(float.TryParse(array[0]), float.TryParse(array[1]), float.TryParse(array[2]));
Then assign it to your transform.
Your answer
Follow this Question
Related Questions
How to Read Data from Excel 2010 in Unity 5.1.2p1? 0 Answers
I can read this information on inspector by script. 0 Answers
Reading .txt file c# problem 0 Answers
Android json read and write 1 Answer
Reading .DAT file 0 Answers