Author: Yashwant Patel
Problem:
As stated in the last blogs one of the problems that players face is not knowing which enemies will spawn from which lanes in the next wave. Currently a lane is unlocked when a boss wave occurs, but a new player won't know which wave elementals will come from. This can cause frustration since the player could build towers in one lane and then be overwhelmed and end up losing and then they have to restart.
Solution:
When I originally started working with spline I thought there was no way to render them. That is still true, but with the use of particles you can actually have them travel along a spline which I recently learned, so this was the solution that I going to implement. The first thing to do was create a Niagra Particle scratch pad. Inside of that it accepts a couple of parameters including spline, age, speed. Then some user parameters are created to match the spline and speed variable in the scratchpad. Using the spline the position and rotation are sampled by unit distance in world space using the age variable. The age variable is used as the distance variable. Inside of the emitter the age variable of the scratchpad is set to the normalized loop age which allows for the looping of the particle. Now the basic particle logic was completed, but a mesh renderer need to be added that would travel along the path. In our case we used an arrow static mesh, but I wanted a custom material on it, so I could have the arrows flash. So time to write a custom shader! I wanted the arrows to be see through and flash with a smoky effect. In order to accomplish I panned a texture, multiplied it by a color.

This gave me colored smoky effect. Now it was time to add some transparency.
So, I took a fresnel node and used a sine wave to oscillate the fresnel power. Using the result of this I multiplied it with the color parameter, so the color of the fresnel could be controlled. The result of this was added on top of the result from the last picture which produced an oscillating sphere with smoky texture, but it was opaque. Last step was to take the result from the fresnel and use that for the opacity. Which produced this.
This material was then used for the mesh of the niagra particle.
Now there were a couple of problems that remained. Each spline in the level isn't the same length, so there needed to be parameters to modify the space between arrows. Another problem was that the arrows were using the transform of the spline, so they were right on the ground. In order to combat this a ZOffset input parameter was added which was used in the scratch pad. Lastly the new map has two lanes that merge into one, so having the particle run across both splines would double up the particles. One way to combat this is to make another spline that only goes up until it meets the other lane and use that spline for the particle, but if one spline is modified then the other one has to be too. The solution I went with was clamping the age and taking the modulus of the max value used in the clamp, so the extra arrows would just spawn at the beginning of the spline rather than at the cutoff point. After tweaking the settings for all the splines it was time to integrate it with the waves. In the wave manager after each wave it checks which lanes has a possibility of spawning elementals next round and it turns on the splines accordingly. Before a round starts they are all deactivated.
This is the final result.
Comments
Post a Comment