While writing a day and night cycle I decided to include some temperature shifting depending on the time of day. After completion I realized that it’d be better to separate a temperature script and day/night cycle script. This is an example of what I have:
In order to do that I had to make _timeOfDay a public static variable. However, I get an error of:
Assets/Custom Assets/Scripts/Environental/Temperature.cs(46,29): error CS0019: Operator >' cannot be applied to operands of type float’ and `GameTime.TimeOfDay’
Anyone know how to resolve this issue? If more information is necessary I’d be more than happy to provide it.
It is a public enum, however I changed things up to where I can use the first script on the temperature script, I made Temperature.cs Derive from GameTime. There are no errors, but it does not calculate temperature when it reaches sunRise.
I don’t know if you’re allowed to call Update if you already declared an Update inside the base class…Same with Start I suppose?
What I would do is that I have a function that is overridden in the child class that is called in Update. So only one instance of Update exists in both parent and child.
Any references that I could check to reference a changed Update to the GameTime script? I tried Temperature.tempUpdate(); and that did not work. The start method works fine, as well as the GUI Buttons, but the Input is not working considering the Controls() function is within the Update for Temperature.cs
Yes this all worked previously before I put them in the Temperature script. I have changed Temperature’s Update to tempUpdate and put:
Temperature temperature = GetComponent<Temperature>();
temperature.tempUpdate();
temperature.Calculate();
temperature.Controls();
At the start of GameTime’s Update function, there are no errors, however it still does not recalculate temperature when the sunrise begins, nor does increasing or decreasing CO2/Oxygen/WaterVapor, ETC. I am going to watch the temperature in the inspector while the game is running to see if it is changing but not displaying the change.
Maybe it’s time to try putting in some debug logs to check the value of _timeOfDay and sunRise to see if that if condition is fulfilled. You might also want to check the boolean value of the variables to see if the input is working. If the input is not working, try moving one out from the function and into Update and test that single input just to see if something was stopping the function from being called (shouldn’t be the case though).
Since changing to the tempUpdate it seems that Skyblending does not work properly, the values of CO2/Methane etc. do change when holding down the increase and decrease button but do not properly display, the temperature does not change, so i am assuming there is something with TimeOfDay
Hmmm am I not supposed to have both scripts in the game scene at the same time? I think it could possibly cause some problems since Temperature inherits from GameTime and pretty much has all of the same variables
Well, you could try removing the parent script from the gameobject in the scene to try it out. It hasn’t caused me any problems when I did that though.
Yeah it doesn’t seem to be working, it does not change the Time of Day, that is one of the main issues, the updating is also an isue. I don’t see why it’s ending up like this, I didn’t mess with time of day variables or anything
I figured out why the values of the atmospheric gases were not changing! I stupidly forgot to put anything relating to the GUIText in the Update Function, so they were never changing. The temperature on the other hand I’m not sure, and the blending not sure either. I ended up putting everything back in to that one script, too annoying at the moment.