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
- This topic has 22 replies, 3 voices, and was last updated 1 year, 4 months ago by
Elvin Sim.
-
AuthorPosts
-
April 1, 2024 at 1:04 am #13665April 1, 2024 at 11:23 am #13666::
Hi Ethan, you need to change the
SceneFader
script’sStart()
function toAwake()
: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>(); } ...April 1, 2024 at 11:50 am #13667April 1, 2024 at 11:50 am #13668April 1, 2024 at 4:05 pm #13673April 1, 2024 at 4:30 pm #13676::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>(); } }
April 1, 2024 at 9:55 pm #13678::Can you add this above line 25 of your
SceneTransition
as well? I’m checking if eitherUIManager.Instance
orUIManager.Instance.sceneFader
is the null value.print(UIManager.Instance); print(UIManager.Instance.sceneFader);
Show me the output on the Console after that.
April 1, 2024 at 11:53 pm #13679April 1, 2024 at 11:59 pm #13680April 2, 2024 at 11:48 am #13683::Try moving the
sceneFader
up toAwake()
: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>();} }April 2, 2024 at 1:03 pm #13685April 2, 2024 at 1:05 pm #13686April 2, 2024 at 1:09 pm #13687April 2, 2024 at 1:16 pm #13688::and also When I am in the part4 tutorial, after my character healing finish, it will cast the fireball at the same time
April 2, 2024 at 1:21 pm #13689April 2, 2024 at 1:21 pm #13690April 2, 2024 at 1:28 pm #13691April 2, 2024 at 2:20 pm #13693::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()
underUpdate()
method is not called after, but before theIf (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.
April 5, 2024 at 12:50 am #13743::Hello, sorry for disturbing, but in part 6 the casting after healing bug fix don’t include in the video
April 5, 2024 at 2:22 am #13746::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.
-
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: