Monday, May 27, 2013

Day/Night!

I'm still waiting on a lot of the logos and assets from my artist, but in the meantime I made a neat little day/night cycle and have fixed some timing bugs!

I also changed the font
The skybox needs to be added still, but I am essentially almost done. Some bugs like seeds not spawning when trees are destroyed and saplings not dying are still on the table to be fixed. There was a huge problem when I added the "day circle" that the times for everything happening all messed up and the circle would start and stop at varying speeds. I fixed this though. Turned out that I have too many debug logs.

Also a quick tip: It took me FOREVER to find this, so I thought I would post a little solution, myself. Getting GUI object the rotate is a lot easier than I thought. A lot of people said it was impossible. But the code looks something like this:

It was a bitch to figure out, though.
Basically, you just use this code. Make sure you create a variable for both the pivot point (it's a vector 2) and the rotation angle (rotAngle). When you set the location of the pivot point, make sure that it is as the location of your image + half the width and - half the height of the image itself. That will place the pivot point of the image directly in it's center.

now keep in mind that this method has it's limitations. Basically, you can only rotate one thing per script (as for some reason, only one pivot point can be applied) and ANYTHING that is made in the GUI function below this script WILL ALSO ROTATE. So I had to make sure everything else was created before this line.

I also discovered that the GUI function will start updating twice as fast when a button on the keyboard is pressed (SUPER IMPORTANT) so the circle would spin faster when I did that. But I had to press buttons to make trees spawn. So, what I did was put the rotation angle in the actual update function (I set it at +0.5f every update) and it all seems to work. I also learned not to put more than a few debug logs in code that updates 1000+ times a second. Slows everything down.

This is all C#, by the way.

No comments:

Post a Comment