Light/Weather Mechanic

I set up my test of the light and weather changing mechanic today. It turned out to be quite difficult, but worked in the end.

I started off by looking at a day/night cycle tutorial which introduced me to the set actor location/rotation and update sun direction modules that I needed.


After that, I started looking at how to adapt this for button press/trigger. I started off by making a button press up the sun speed to make it change rapidly.


I then added a branch to change a vector variable, sun height, based on what the variable was already set at. This vector was designed to represent the pitch, yaw and roll of the rotation.


This wasn’t working properly, so I started using strings to debug and check what was going on.


I found that the issue was to do with how the variable was set at the start, so I set the sun height to be equal to the current rotation of the sun light.


I then added branches and variables 3 light states. The game will check if the light state matches any of the ones set up and change it accordingly. This worked, but there were bugs and quite often it would just stop working.


After showing my blueprints to some programmers, I got the suggestion of using a switch and enums rather than comparing vectors. This took a while to set up, but was way less buggy than before. I set up 3 states and declared those states, rather than the light vectors. I then used the light vectors within these states.


At this point I wanted to start making some real light set ups that resembled my final ideas for lighting. This is where I discovered a big mistake – the vectors had no bearing on actual rotations. My first idea was that this was because they were in radians, so I used a converter online, but they still acted completely unexpectedly. After looking at the documentation it turned out that there was actually a rotator variable type all along. I was kicking myself a bit here, and went back and replaced my vectors with rotators. This meant I was able to create three light states – bright, dark and overcast. The overcast didn’t look great, and I have a lot of work to do with colour, fx and weather but the code works well. I feel like the feel is good right now and will only get better with proper art.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s