Forum begins after the advertisement:


[Part 5] My SceneFader cannot function

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [Part 5] My SceneFader cannot function

Viewing 20 posts - 1 through 20 (of 23 total)
  • Author
    Posts
  • #13665
    Elvin Sim
    Level 10
    Participant
    #13666
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    Hi Ethan, you need to change the SceneFader script’s Start() function to Awake():

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    using UnityEngine.SceneManagement;
    
    public class SceneFader : MonoBehaviour
    {
        [SerializeField] private float fadeTime;
    
        private Image fadeOutUIImage;
    
        public enum FadeDirection
        {
            In, 
            Out
        }
    
        // Start is called before the first frame update
        void Start() Awake()
        {
            fadeOutUIImage = GetComponent<Image>();
        }
    
        ...
    
    #13667
    Elvin Sim
    Level 10
    Participant
    #13668
    Elvin Sim
    Level 10
    Participant
    Helpful?
    Up
    0
    ::

    Still Cannot

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

    Can you show me your UIManager script? If you can show this in text, it will be great.

    #13676
    Elvin Sim
    Level 10
    Participant
    Helpful?
    Up
    0
    ::
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class UIManager : MonoBehaviour
    {
        public static UIManager Instance;
    
        private void Awake()
        {
            if (Instance != null && Instance != this)
            {
                Destroy(gameObject);
            }
            else
            {
                Instance = this;
            }
            DontDestroyOnLoad(gameObject);
    
        }
    
        public SceneFader sceneFader;
    
        private void Start()
        {
            sceneFader = GetComponentInChildren<SceneFader>();
        }
    }
    #13678
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    Can you add this above line 25 of your SceneTransition as well? I’m checking if either UIManager.Instance or UIManager.Instance.sceneFader is the null value.

    print(UIManager.Instance);
    print(UIManager.Instance.sceneFader);

    Show me the output on the Console after that.

    #13679
    Elvin Sim
    Level 10
    Participant
    Helpful?
    Up
    0
    ::

    okok

    #13680
    Elvin Sim
    Level 10
    Participant
    #13683
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    Try moving the sceneFader up to Awake():

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class UIManager : MonoBehaviour
    {
        public static UIManager Instance;
    
        private void Awake()
        {
            if (Instance != null && Instance != this)
            {
                Destroy(gameObject);
            }
            else
            {
                Instance = this;
            }
            DontDestroyOnLoad(gameObject);
            sceneFader = GetComponentInChildren<SceneFader>();
        }
    
        public SceneFader sceneFader;
    
        private void Start()
        {
            sceneFader = GetComponentInChildren<SceneFader>();
        }
    }
    #13685
    Elvin Sim
    Level 10
    Participant
    Helpful?
    Up
    0
    ::

    thank you it function now

    #13686
    Elvin Sim
    Level 10
    Participant
    Helpful?
    Up
    0
    ::

    but now when my character healing, it will always stuck at the player_heal animation

    #13687
    Elvin Sim
    Level 10
    Participant
    #13688
    Elvin Sim
    Level 10
    Participant
    Helpful?
    Up
    0
    ::

    and also When I am in the part4 tutorial, after my character healing finish, it will cast the fireball at the same time

    #13689
    Elvin Sim
    Level 10
    Participant
    Helpful?
    Up
    0
    ::

    and also when the player is transitioned to another scene the mana UI is being filled

    #13690
    Elvin Sim
    Level 10
    Participant
    Helpful?
    Up
    0
    ::

    when the player is transitioned to another scene the mana UI is being filled

    #13691
    Elvin Sim
    Level 10
    Participant
    #13693
    Joseph Tang
    Level 13
    Moderator
    Helpful?
    Up
    0
    ::

    1. Your Player is stuck in healing.

    If this does not work, we may need to get more information to identify the issue.
    [Part 4] Player gets stuck in the heal state and does not heal

    In your PlayerController.cs, check if Heal() under Update() method is not called after, but before the If (pState.healing) return;code.

    2. Casting after healing

    In Part 6 a bugfix was discussed for this.
    Creating a Metroidvania (like Hollow Knight) — Part 6: Enemies, Spikes, and an Advanced Camera

    This fix should solve the issue.

    3. Mana UI is filled after scene transition

    What is possibly happening is there are multiple instances of your mana UI in the scene. Ensure that only your starting scene has a Player and a Canvas, all other scenes should not have their own Canvas or Player.

    If any of these do not work, feel free to update us.

    #13743
    Elvin Sim
    Level 10
    Participant
    Helpful?
    Up
    0
    ::

    Hello, sorry for disturbing, but in part 6 the casting after healing bug fix don’t include in the video

    #13746
    Joseph Tang
    Level 13
    Moderator
    Helpful?
    Up
    0
    ::

    Sorry for the confusion, but I believe this fix was only added in the Forum above:

    Creating a Metroidvania (like Hollow Knight) — Part 6: Enemies, Spikes, and an Advanced Camera

    I do think the video was made before the Forum, or the Forum was updated later to include the fix. If the fix shown above does not work, do inform us for further assistance.

Viewing 20 posts - 1 through 20 (of 23 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: