Forum begins after the advertisement:


[Part 9] Missing Video Content, Common Issues & Fixes

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [Part 9] Missing Video Content, Common Issues & Fixes

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #14654
    Joseph Tang
    Moderator

    This is a supplementary post written for Part 9 of our Metroidvania series, and it aims to address 1 thing:

    1. Missing information in the video.

    For convenience, below are the links to the article and the video:


    Table of Contents

    Missing Information in the Video

    1. Multiple Jump audio clips being played on first jump
    2. Cast sound playing despite ability being locked
    3. Exiting to Main Menu does not save the game
    4. 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.cs CastCoroutine().
    • Add audioSource.PlayOneShot(spellCastSound); into each of the If statements under CastCoroutine() with the parameter of unlocked___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;
        }

    [This is caused by a missing code]

    • Add a SaveGame() method to GameManager.cs to call SaveGame() when quitting to Main Menu
    • Then, on the “Quit to Main Menu” button’s On-Click() inspector, add the SaveGame() method.
        public void SaveGame()
        {
            SaveData.Instance.SavePlayerData();
        }

    Add the SaveGame() method to the button’s On-Click() event

    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 of Time.unscaledDeltaTime while the time scale has been set to 0. Thus, to fix this, switch the Time.deltaTime for Time.unscaledDeltaTime.

    Set Pause Menu and it’s children to Active.
        IEnumerator FadeOut(float _seconds)
        {
    	...
    	canvasGroup.alpha = 1;
    	while (canvasGroup.alpha > 0)
    	{
    		canvasGroup.alpha -= Time.deltaTime Time.unscaledDeltaTime / _seconds;
    		yield return null;
    	}
    	yield return null;
        }
    	
        IEnumerator FadeIn(float _seconds)
        {
    	canvasGroup.alpha = 0;
    	while (canvasGroup.alpha < 1)
    	{
    		canvasGroup.alpha += Time.deltaTime Time.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.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: