This week also includes the mid semester breaks work and so and it will be longer. I've decided to continue on polishing and although adding new stuff is always more exciting and attractive, I am aware of scope creep and want to have a complete project by the end of the semester.
The first thing I did was add a particle effect for when the player travels over sand and water. Inspired by anime's like Cowboy Bebop I took a stylised approach and created jagged triangular shapes to project out from underneath the jet. This helps to give the illusion of water and sand particles being pushed out of the way by the aerodynamics of the jet and is an extra level of detail I love. I created a little script that works by simply turning on the particle effect when within trigger area, the opposite for how my rain effect works.
As it's grayscale I simply lower the opacity which allows it to blend to the colour of the terrain it is over.
A quick thing I added was a boost pad to my desert level to help with allowing the player to beat the NPC. As it is now the final level I think that it's okay for them to be difficult and so I have not altered there recordings but I did make the experience a little more lenient by adding the boost for the player to utilise on the back straight of the map.
During the break I was emulating Burnout Dominator (great game) when I noticed that the cars seem to have shadow underneath them by simply having a plane sprite placed under them. I have come to this conclusion due to being able to see the wheels clip through the plane during some level cut scenes. I decided to add this to my game as well to achieve more accurate looks and so got rid of the accurate shadow and simply used a sprite placed underneath the jet to create it. I had to actually place it quite a bit higher above the ground due to elevation changes to stop clipping however due to the camera angle the player can not tell. I then altered the hover jet code to turn off the shadow sprite once the raycast that is used for hovering stops detecting ground. In layman's terms now it means that when the jet goes off a drop or jump it enters the isFalling state, and so the shadow disappears from underneath the jet.
if (isOnGround)
{
//other code here
shadow.SetActive(true);
}
else
{
//other code here
shadow.SetActive(false);
}
I then got around to adding more audio, including npc engines, wallgrind, and level select BGM as these were all missing from the player expereince.
After this I then went back to the UI and updated all the menu's button sprites to match the main menu. I then decided to make traversal and readability easier as during playtesting I noticed players confused on what button was currently selected. I did this trough updating the selected button sprite to be blue with a glow around it.
This was an instant improvement. After this I went about finally fleshing out my main menus sub menus, adding a new credits page and actually getting the settings page working. The credits page just simply lists all the music I use as well as naming me as the creator and developer of the game. The settings page was a lot more complicated to get running.
This page is used to alter all the audio levels within the game and so I needed to first get the sliders to control my audio mixers and second, save them to player preferences within Unity so that the changes stay across scenes. I also added a reset button to allow the player to set them back to defaults in case of breaking the audio badly.
I did this through an audio script. The script uses an array for the audio mixers and so I have a string which lists them
private string[] volumeParams = { "Master", "Music", "Effects", "Ambience", "UI", "AIEngines", "Engine" };
I then have a corresponding array for there default values and a string for that as well.
private float[] defaultDbValues = { -19f, 4f, 10f, -6f, 10f, -9f, -8f };
In the start function it then loads the saved player preferences or uses the default in cases of none.
float savedVolume = PlayerPrefs.GetFloat(volumeParams[i], GetSliderValueFromDb(defaultDbValues[i]));
audioSliders[i].value = savedVolume;
audioMixer.SetFloat(volumeParams[i], LinearToDb(savedVolume));
int index = i;
audioSliders[i].onValueChanged.AddListener(value => SetVolume(index, value));
To actually utilise the sliders confusing maths occurs to conver the linear slider to decibals of the mixer. It's something I found in the tutorial and don't understand the maths but is used to make the sliders increase and decrease of sound 'normal.'
float sliderValue = Mathf.InverseLerp(minDb, maxDb, dbValue);
This then allows us to set the sliders to a value of 0 -1 that corresponds with the mixer and thats how the interaction between the sliders value and the mixers -80 to 20 value works.
public void SetVolume(int sliderIndex, float volume)
{
audioMixer.SetFloat(volumeParams[sliderIndex], LinearToDb(volume));
PlayerPrefs.SetFloat(volumeParams[sliderIndex], volume);
}
Setting the audio to default is basically the same except instead of taking the sliders value and using that as a float we take the default value and set it as the volume levels
audioMixer.SetFloat(volumeParams[i], LinearToDb(defaultSliderValue));
Overall the sound script is confusing and very complicated to my mainly art focused brain and so I'm glad tutorials and coding resources exist. Im just happy it works!
As always here is a playthrough of the changes:
Comentarios