Forum begins after the advertisement:


[Part12] Regarding some operational issues in the article

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [Part12] Regarding some operational issues in the article

Viewing 20 posts - 21 through 40 (of 48 total)
  • Author
    Posts
  • #16928
    MI NI
    Level 16
    Former Patron
    Helpful?
    Up
    0
    ::

    Maybe the translation caused me to express something wrong. When I didif (!audioSource) return;, Null was not generated. This should mean that feedbackConfig is fine. However, if (!audioSource) return; A Null message will be generated. I don’t know if my understanding is wrong.

    As for the second question, I want to ask whether I should place the sound effects and AudioMixer under the UIAudioData folder

    #16929
    MI NI
    Level 16
    Former Patron
    Helpful?
    Up
    0
    ::

    Oh, I think I found the error. I’ve been thinking that I don’t have GetComponent. Because it didn’t mark it out, I thought it wasn’t needed, but I just checked the article’s code and it has GetComponents<AudioSource>

    Sorry for causing you trouble

    These lines in the article

            // Find an audio source in itself, or a parent object (e.g. Canvas).
            audioSource = GetComponentInParent<AudioSource>();
            if (!audioSource && feedbackConfig)
                Debug.LogWarning($"No Audio Source found in parent! {name} will not have any audio feedback!");
    #16933
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    Glad you found the issue @mini

    #16946
    MI NI
    Level 16
    Former Patron
    Helpful?
    Up
    0
    ::

    I would also like to ask which function of UIScreen is called when starting the game from the main screen. This part does not seem to be mentioned in the article.

    When I created the Pause Menu and Quit To MainMenu, the picture in the article called LoadScene, but I did not have this function to call.

    View post on imgur.com
    #16947
    Ser Apustaja
    Level 6
    AI Assistant
    (BETA)
    Helpful?
    Up
    0
    ::

    Hello MI NI (mini)!

    When starting a game from the main screen, the function application(_:didFinishLaunchingWithOptions:) in the UIApplicationDelegate protocol is usually called. This function is part of the app delegate and is responsible for setting up your app and preparing it for use. Within this function, you can perform any necessary setup tasks, such as initializing game components and setting up the initial UI.

    If you have any more questions or need further clarification, feel free to ask!

    #16949
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    @Mini copy the UIScreen code from the article again. I’ve added another 2 overloads to the UIScreen script so that we can use it in the Inspector:

    // These are single-argument versions of the below functions,
    // so that buttons are able to make use of them in the editor.
    public virtual void LoadScene(string sceneName) { LoadScene(sceneName, -1); }
    public virtual void LoadScene(int buildIndex) { LoadScene(buildIndex, -1); }
    
    public virtual void LoadScene(string sceneName, float fadeDuration = -1)
    {
        LoadScene(SceneUtility.GetBuildIndexByScenePath(sceneName), fadeDuration);
    }
    
    public virtual void LoadScene(int buildIndex, float fadeDuration = -1)
    {
        StartCoroutine(LoadScene(buildIndex, LoadSceneMode.Single, fadeDuration));
    }
    #16961
    MI NI
    Level 16
    Former Patron
    Helpful?
    Up
    0
    ::

    I encountered a problem again. When I pressed pause, the pause menu would not appear, but it was successfully enabled. I also clicked the button, but there was no screen. When I pressed the continue game button, the pause menu would Fade in and out. Then I tested the button to exit the game, After I press the exit button, the Fader (Temp) object will not return to the main screen. It will not jump to the main menu until I press the pause menu (ESC) again.

    #16963
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    Make sure the Time Scale Mode of both the pause and death screens are set to Nothing. Currently, it is set to Affected by Global Timescale, which causes them to be affected by game pauses.

    #16971
    MI NI
    Level 16
    Former Patron
    Helpful?
    Up
    0
    ::

    He solved it, but when I exit to the main menu, I also need to release the pause state (ESC) before exiting to the main screen. Otherwise, the screen will still remain in the paused state.

    #16972
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    @Mini in this case, you can add an unpause action (GameManager > Pause with unchecked checkmark) to your quit to main menu button as well. The unpause action will cause time to go back to normal.

    #16974
    MI NI
    Level 16
    Former Patron
    Helpful?
    Up
    0
    ::

    I found that if the player dies, my monster will move forward uncontrollably, or it will be completely stuck and will not move, and the player cannot use healing health after death.

    #16976
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    I will be improving on the health / mana UI and mechanics in the next part. Doing a stream on Tuesday.

    EDIT: Regarding the healing, it should still be working. But you will need to hit some enemies to restore your mana first.

    #16993
    MI NI
    Level 16
    Former Patron
    Helpful?
    Up
    0
    ::

    At the end of the video, I attacked monsters after resurrecting until I fully restored Mana. I jumped on the platform and tried to heal health, but it had no effect. Other functions could still be used normally.

    #16994
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    Can you share your project over Google Drive? I’ll help you have a look.

    #16996
    MI NI
    Level 16
    Former Patron
    Helpful?
    Up
    0
    ::

    I tried to email you the cloud URL of the project, but it couldn’t be sent. Which email address should I send it to you from?

    #17004
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    I reached out to you via email. You can send me your project there.

    #17006
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    @mini, I found your issue. It’s not a problem with your healing. Your UI is not updating after you reset your character’s health back to 100 after respawn. So you are unable to heal because you are actually at max health.

    Only after you get hit once by the enemy, the healthbar updates and everything will function normally afterwards.

    View post on imgur.com

    Make sure you update your healthbar when you respawn the player.

    #17009
    MI NI
    Level 16
    Former Patron
    Helpful?
    Up
    0
    ::

    Thanks for your tip, I corrected him. But some problems occurred when I was testing other functions. I found that when I switched scenes, blackFade would not disappear and an error message would be generated. I didn’t know what to do.

    #17010
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    Can you post your code that is causing the error here and specify the line where the MissingReferenceException is? The AI will be better suited to help you here.

    Do a print(name) above the group.alpha line (the one with the error) as well and tell me what the output is as well.

    #17011
    MI NI
    Level 16
    Former Patron
    Helpful?
    Up
    0
    ::
    MissingReferenceException: The object of type 'CanvasGroup' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    UIScreen+<Fade>d__24.MoveNext () (at Assets/Script/UI/UIScreen.cs:180)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <3b24cc7fa9794ed8ab04312c53e6dedd>:0)
        protected virtual IEnumerator Fade(float duration, int direction = 1)
        {
            WaitForSecondsRealtime w = new WaitForSecondsRealtime(updateFrequency);
    
            // Don't play as long as another animation is playing on this.
            while (isAnimating) yield return w;
    
            isAnimating = true;
            float currentDuration = duration;
    
            group.alpha = direction > 0 ? 0 : originalAlpha;
            gameObject.SetActive(true);
            while (currentDuration > 0)
            {
                yield return w;
                float timeScale = GetTimeScale();
                if (timeScale <= 0) continue;
                currentDuration -= w.waitTime * timeScale;
                float ratio = currentDuration / duration;
                print(name);
                <strong>group.alpha = (direction > 0 ? 1f - ratio : ratio) * originalAlpha;</strong>
            }
    
            group.alpha = direction > 0 ? originalAlpha : 0;
    
            if (direction < 0) gameObject.SetActive(false);
    
            isAnimating = false;
        }
    View post on imgur.com
Viewing 20 posts - 21 through 40 (of 48 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: