Code
While doing the latter, I've managed to actually increase the fps! It's mainly due to the grass; theres around 400 individually placed grass objects. Each with an enemy script for how they interact with the player i.e. cutting. So because some 400 peices are constanly checking if they've been cut or not it bogs down the game quite a lot, I think it goes from 90+ fps to nearly 40 fps, which is a huge drop.
I had an idea though, because the grass deosn't need to check their status until the player is right within their vacinity, I added another code to check exactly this and enable / disable if close enough, lo and behold it works!
The game is more that 60fps again, its still a bit slower due to the sheer amount of grass objects, but its instantly better.
The code is insanely easy, no more than 3 lines. I guess 400 objects checking their distance to the player once a frame is much more efficient than 400 objects checking their behaviour state many times a frame.
Also I added in the random Rupee code I discussed in a previous post, seeing how the grass is working in game, figured might aswell clean its code up and add random chance to spawn one.
They now have a 1/10 chance to spawn, which feels about right.
Effects
I've also been working on implementing effects throughout, such as wind streaks, waves, clouds etc.
In this scene you can see all of the previously mentioned working in tandem.
The waves and clouds are both particle emitters and both replicate how they look in Windwaker. The wind streaks were a bit trickier, these are actually line renderers. I initially modelled the wind and animated the texture to scroll through, giving the effect it's moving. Though when I spawned them, the material was shared, so they all scrolled at the same time which looked aweful.
After many hours I asked a friend his opinion and he coded a small script creating the same effect using maths, which is beyond my skill set.
User Interface
The interface is pretty much complete. Hearts, Rupees and Swim Gauge all work. The button text is next, I simply need to change these at runtime depending on current situation and is easy enough.
Hardest aspect was the Swim Gauge. It has many things going on, for example when the player enters water it gradually depletes, there's also a sheen that flashes over it. Then to top it off, it needs to be reset upon entering the water.
Most of this was achieved via masks, the gauge drain was done with a square mask, its pivot set at the bottom and it's height reduced over time.
It does have two more effects, which I havn't included because I don't think they're warranted and would look quite complex and out of place for the demake. These were a particle emitter firing off little spheres above it and then the whole globe would flash red nearer to death (I may include this yet).
Sounds
The final aspect of this project is the inclusion of sounds. I wish I had done this as and when I needed them, but it doesn't matter.
A nice and easy way to fire specific sounds I found is using animation events. These are little triggers I can attach to any animation frame, which then tells a script to do a particular function.
If you look at the timeline above, near the 0:17 mark you can see I've added an event to trigger "Swim", which is as he does a breast stroke. I then have a sound manager script I made and added it to the player, which solely waits for these events, which can trigger from any animation:
Other sounds are easy enough and can be place on prefebs and triggered when needed.
Finishing Up
Once these are done the rest are just little tweaks! It's pretty much complete as is (minus sounds). I may see what else I can add in the mean time.
No comments:
Post a Comment