Overview
This week, I devoted all my time to completing the spotlight effect, and I finally achieved the desired outcome. Once it was finished, I dedicated the remaining time to integrating the spotlight effect with some of my existing mechanisms.
Spotlight Effect Development
First and foremost, I want to express my thank to the individual who commented to me previously, offering a tutorial. Even though I wasn't able to use the same method as visual programming from the tutorial to accomplish the task, it still served as a significant source of inspiration for me.
Tutorial Link:
https://www.youtube.com/watch?v=S5gdvibmsV0
In the part of shader programming, most of them belong to the use of mathematical formulas. After following some tutorials in the video and with the help of research, I made two spotlight circles that I need to use.
Then if we want to adjust these spotlight effects in real-time in the Unity Inspector, we have to write these variables in the properties of the script.
(Shader Script)
(Unity Inspector)
Moving forward, my next step is to integrate this with my current mechanism. In the rules I established earlier, it was stipulated that at the beginning of each level, the light would manifest solely in two specific locations: the exit and the light source. Therefore, I must now make the necessary adjustments to the positioning of my spotlight circle within both my pre-existing light source script and exit script.
Both scripts use the same method to add the function of UpdateSpotlightPosition. It will adjust the relative position of my two Spotlight circles according to the position of the GameObject in my scene.
(Light Source and Exit Script)
Finally, it is the player. Once the player picked up the light, the spotlight would follow the player around. This is also quite similar to what we just did to the light source and exit. By the bool, we set previous to check if the player already picked up the light source. If yes, then the _SpotlightCenter will start following the player around.
(PlayerMovement Script)
Note: The Exit and Player's UpdateSpotlightPostion functions will need to remain in Update() since they will continue to place the GameObject in Spotlight even if it moves. And so far the Light source is not needed, because in the design, it does not currently move.
Demo
Game Version 3 Play Test Link:
https://0maple0.itch.io/lights-alpha
Next Week
So far, all the game mechanisms designed in my game have been completed. In the remaining time, I will concentrate on designing the game plot and levels. In the game, I will also try to add more assets to make the game as beautiful as possible.
Comments
Post a Comment