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 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #13665
    Elvin Sim
    Level 10
    Participant
    #13666
    Terence
    Level 30
    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 30
    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 30
    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 30
    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

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

Go to Login Page →


Advertisement below: