by following this youtube tutorial, i am able to get values from flightgear through http interfacing. however, while following the unity document to set, the values does not update in flightgear.
the webrequest returns success and no exception caught but the value remains the same in flightgear.
the command i'm trying is "position/altitude-ft". i tried setting the value on the browser and it immediately reflects in flightgear, thus i'm certain that the variable can be set but i'm not sure why the set is not working.
will be great if anyone can let me know if its the wrong command or if there is something missing from my code.
any help appreciated.
- Code: Select all
public async void Set<T>(string command, T val)
{
using UnityWebRequest webRequest = UnityWebRequest.Post("localhost:5050/json/" + command, val.ToString());
// request and wait for to connect to the server
UnityWebRequestAsyncOperation operation = webRequest.SendWebRequest();
while (!operation.isDone)
{
await Task.Yield();
}
// if fail
if (webRequest.result != UnityWebRequest.Result.Success)
this.Log($"Error: {webRequest.error}", Color.red, false);
}
edit: added the url for connecting