Forum begins after the advertisement:
[Part 9 Bug Fixes] Pause Menu Doesn’t Appear, Audio Issues
Home › Forums › Video Game Tutorial Series › Creating a Metroidvania in Unity › [Part 9 Bug Fixes] Pause Menu Doesn’t Appear, Audio Issues
- This topic has 0 replies, 1 voice, and was last updated 7 months, 1 week ago by Joseph Tang.
-
AuthorPosts
-
May 14, 2024 at 4:09 pm #14654::
This is a supplementary post written for Part 9 of our Metroidvania series, and it aims to address 1 thing:
- Missing information in the video.
For convenience, below are the links to the article and the video:
- Article Link: https://blog.terresquall.com/2023/08/creating-a-metroidvania-like-hollow-knight-part-9/
- Video Link: https://youtu.be/vPi6ZXbiCsk
Table of Contents
Missing Information in the Video
- Multiple Jump audio clips being played on first jump
- Cast sound playing despite ability being locked
- Exiting to Main Menu does not save the game
- Pause menu doesn’t appear when pausing
Missing Information in the Video
1. Multiple Jump audio clips being played on first jump
[This is caused by the “Update()” function calling the code for the sound clip multiple times for the amount of frames its If statement’s parameter conditions are met.]
- Replace the “audioSource.PlayOneShot(jumpSound)” to “if (Input.GetButtonDown(“Jump”)) {audioSource.PlayOneShot(jumpSound);}” to PlayerController.cs “Jump()” function’s first If statement.
void Jump() { if (jumpBufferCounter > 0 && coyoteTimeCounter > 0 && !pState.jumping) {
audioSource.PlayOneShot(jumpSound)if (Input.GetButtonDown("Jump")) { audioSource.PlayOneShot(jumpSound); } ... }
2. Cast sound playing despite ability being locked
[This is caused by the player being able to press the casts’ keys even if they’re locked.]
- Remove the
audioSource.PlayOneShot(spellCastSound);
in the PlayerController.csCastCoroutine()
. - Add
audioSource.PlayOneShot(spellCastSound);
into each of the If statements underCastCoroutine()
with the parameter ofunlocked___Cast
.
IEnumerator CastCoroutine() {
audioSource.PlayOneShot(spellCastSound);//side cast if ((yAxis == 0 || (yAxis < 0 && Grounded())) && unlockedSideCast) { audioSource.PlayOneShot(spellCastSound); ... } //up cast else if( yAxis > 0 && unlockedUpCast) { audioSource.PlayOneShot(spellCastSound); ... } //down cast else if((yAxis < 0 && !Grounded()) && unlockedDownCast) { audioSource.PlayOneShot(spellCastSound); ... } anim.SetBool("Casting", false); pState.casting = false; }
3. Exiting to Main Menu does not save the game
[This is caused by a missing code]
- Add a
SaveGame()
method to GameManager.cs to callSaveGame()
when quitting to Main Menu - Then, on the “Quit to Main Menu” button’s
On-Click()
inspector, add theSaveGame()
method.
public void SaveGame() { SaveData.Instance.SavePlayerData(); }
4. Pause menu doesn’t appear when pausing
[While there may be more, these are 2 possibilities]
- 1. Pause menu is not Set Active in the Canvas. Simply set the Pause menu and it’s children to active as they are being shown through their Canvas Group Alpha rather than Active or Inactive.
- 2. FadeUI.cs is using
Time.deltaTime
instead ofTime.unscaledDeltaTime
while the time scale has been set to 0. Thus, to fix this, switch theTime.deltaTime
forTime.unscaledDeltaTime
.
IEnumerator FadeOut(float _seconds) { ... canvasGroup.alpha = 1; while (canvasGroup.alpha > 0) { canvasGroup.alpha -=
Time.deltaTimeTime.unscaledDeltaTime / _seconds; yield return null; } yield return null; } IEnumerator FadeIn(float _seconds) { canvasGroup.alpha = 0; while (canvasGroup.alpha < 1) { canvasGroup.alpha +=Time.deltaTimeTime.unscaledDeltaTime / _seconds; yield return null; } ... }
That will be all for Part 9. Hopefully this can help you on any issues you may have. However, if you find that your issues weren’t addressed or is a unique circumstance, you can submit a forum post to go into detail on your problem for further assistance.
-
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: