Sebastian
Accessing data for multiple days from weather api
To see why this is important (for
HttpClient
specifically) look here (if interested): https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-net-http-httpclient#instancing19 replies
Physics
Have you read the documentation? https://docs.unity3d.com/6000.0/Documentation/ScriptReference/MonoBehaviour.FixedUpdate.html
MonoBehaviour.FixedUpdate has the frequency of the physics system; it is called every fixed frame-rate frame. Compute Physics system calculations after FixedUpdate. 0.02 seconds (50 calls per second) is the default time between calls. Use Time.fixedDeltaTime to access this value.This would seem to be what you want:
2 replies
Accessing data for multiple days from weather api
Here are some additional pointers:
1. Move the API key out of your code entirely, load it from a local configuration file. Make sure that the configuration file is not tracked by a versioning system (so if you are using git, add it to .gitignore)
2. Don't initialize
HttpClient
repeatedly. This is especially bad with this type.
3. Always return early if you can (google "c# return early" if you don't know what I mean)
4. You were checking whether the HttpClient
was null
right after creating it (so it should never be null, the condition is useless)
5. Ideally you should replace JObject
with something else
6. You forgot to dispose the object in response
variable
19 replies
Accessing data for multiple days from weather api
You probably need to call a different API endpoint
See the docs here https://openweathermap.org/api
19 replies