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
- This topic has 46 replies, 4 voices, and was last updated 7 months, 3 weeks ago by
Terence.
-
AuthorPosts
-
December 27, 2024 at 1:17 am #16928::
Maybe the translation caused me to express something wrong. When I did
if (!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
December 27, 2024 at 1:23 am #16929::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!");
December 27, 2024 at 2:06 pm #16933December 27, 2024 at 9:47 pm #16946::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
December 27, 2024 at 10:11 pm #16947::Hello MI NI (mini)!
When starting a game from the main screen, the function
application(_:didFinishLaunchingWithOptions:)
in theUIApplicationDelegate
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!
December 28, 2024 at 1:18 pm #16949::@Mini copy the
UIScreen
code from the article again. I’ve added another 2 overloads to theUIScreen
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)); }
December 28, 2024 at 10:00 pm #16961::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.
December 28, 2024 at 10:09 pm #16963::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.
December 29, 2024 at 6:59 pm #16971::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.
December 29, 2024 at 7:24 pm #16972December 29, 2024 at 8:10 pm #16974::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.
December 29, 2024 at 11:51 pm #16976::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.
December 31, 2024 at 6:24 pm #16993::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.
January 1, 2025 at 8:31 pm #16994January 2, 2025 at 12:21 pm #16996::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?
January 2, 2025 at 6:16 pm #17004January 3, 2025 at 12:24 am #17006::@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.
January 3, 2025 at 6:37 pm #17009::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.
January 3, 2025 at 10:59 pm #17010::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 thegroup.alpha
line (the one with the error) as well and tell me what the output is as well.January 3, 2025 at 11:21 pm #17011::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
-
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: