now im able to read the info in my text file, but can any 1 tell me how can i use the infomation in my text file to change the position of my character?
this is in my text file
pos x = -4.2
pos y = 0.4
pos z = -5.9
this is my c# code
using UnityEngine;
using System;
using System.IO;
class textEditor : MonoBehaviour
{
string path = @"C:\Desktop\textcreatingTest\Assets\MyTXT.txt";
public string fileName = "MyTXT.txt";
public GameObject player;
void Update()
{
if (!File.Exists(path))
{
Debug.Log(fileName + " does not exist.");
return;
}
using (StreamReader sr = File.OpenText(path))
{
String fileData;
fileData= sr.ReadToEnd();
sr.Close();
Debug.Log("Data Read: " + fileData);
}
}
}
I’ma add to this- if any if you ever modded the GTA series on PC, then you’ll know you get .dat files- practically tables of data for each thing. Just wondering if that is feasable.
One way is to read your string a line at a time, and split each line into tokens. If you tokenise using spaces the 4th token will be the value you are after (after converting to a float).
I also added “code” tags to your post so it is easier to read. Please use around any code pasted in a post to make it readable.
SchoolProject!
Welcome to the Unity3D forums. If you need answers, try the custom search engine in my signature. For additional learning resources check out the links below. If you can’t find what you need, drop me a line and I will try to point you in the correct direction.