Forum begins after the advertisement:
Search Results for 'fader'
-
AuthorSearch Results
-
January 6, 2025 at 1:42 pm #17044TerenceKeymaster
Managed to fix your problem. The Fader is coming from your UIManager’s entrance animation. I modified your UIManager’s Awake function so that it calls
base.Awake()
only if it is not destroyed. Otherwise, if you have duplicate UIManagers on the Scene, they will trigger the entrance fade and get destroyed before they are able to clean up the fade animation.public class UIManager : UIScreen { public static UIManager Instance; //¨¾¤î¦hÓ«½Æªºª±®a¸}¥»¥X²{ [Header("UI Manager")] public GameObject mapHandler; //¦a¹Ï public GameObject inventory; //I¥] public UIScreen deathScreen; protected override void Awake() { if (Instance != null && Instance != this) { Destroy(gameObject); return; } base.Awake(); DontDestroyOnLoad(gameObject); Instance = this; //new } }
One more thing as well: You don’t need an entrance animation for your UIScreen, because the SceneTransition script already handles the fade in / fade out.
January 5, 2025 at 4:37 pm #17022MI NIBronze Supporter (Patron)Yes, my QuitToMainMenu uses UIManager’s LoadScene, but my problem is that the Fader (Temp) will not be deleted when I switch scenes, but the player can still move freely, including using the pause menu, but the screen will be black. (Fader(Temp))
December 28, 2024 at 10:00 pm #16961MI NIBronze Supporter (Patron)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.
November 27, 2024 at 8:23 pm #16576A_DONUTModeratorLet’s go through each of your issues step-by-step:
1. Console Error in
UIManager
:The error might be related to how
DontDestroyOnLoad()
is interacting with other scripts or objects. Ensure thesceneFader
component is properly linked, and double-check if yourUIManager
object exists in the scene hierarchy.Potential fixes:
- Ensure that
SceneFader
is attached as a child object in the inspector. - Check for duplicate
UIManager
objects when the scene reloads. - Add
Debug.Log
to verify thesceneFader
assignment.
2. Bat Stun Issue:
Problem: The bat gets stunned even if
stunDuration
is set to 0 and also gets stunned/knockbacked after dying.Fixes:
-
Check stun logic:
InEnemyHit()
, ensure the bat only gets stunned if thestunDuration
is greater than zero:csharp if (health > 0 && stunDuration > 0) { ChangeState(EnemyStates.Bat_Stunned); } else if (health <= 0) { ChangeState(EnemyStates.Bat_Death); } <code></code>
-
Disable collision after death:
InDeath()
, ensure that the bat no longer processes hit logic or collisions:csharp protected override void Death(float destroyTime) { base.Death(destroyTime); rb.velocity = Vector2.zero; // Stop all movement rb.gravityScale = 12; GetComponent<Collider2D>().enabled = false; // Disable collisions } <code></code>
3. Jumping Too High:
Problem: The character sometimes jumps too high when you lightly tap the jump button.
Fix: Adjust the
Jump()
method to apply a minimum height and reduce velocity more smoothly:csharp if (Input.GetButtonUp("Jump") && rb.velocity.y > 3) { rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * 0.5f); // Reduce, but don't cancel instantly } <code></code>
Also, ensure
jumpBufferCounter
andcoyoteTimeCounter
are reset correctly after jumps.
4. Walljumping Issue (Directional Problems):
Problem: Walljumping works only on the right-side wall correctly.
Fix: Ensure the walljump direction logic is symmetrical:
csharp if (Input.GetButtonDown("Jump") && isWallSliding) { isWallJumping = true; float jumpDirection = pState.lookingRight ? -1 : 1; // Simplified for clarity rb.velocity = new Vector2(jumpDirection * wallJumpingPower.x, wallJumpingPower.y); Invoke(nameof(StopWallJumping), wallJumpingDuration); } <code></code>
Also, remove any unnecessary
transform.eulerAngles
adjustments unless flipping visually.
5. Camera Reset After Scene Transition:
Problem: Returning to a previous scene doesn’t set the correct camera position.
Fix: Store the current camera or position before transitioning:
csharp public Vector3 lastCameraPosition; // Before transitioning scenes lastCameraPosition = Camera.main.transform.position; // After loading the scene, reset the camera Camera.main.transform.position = lastCameraPosition; <code></code>
6. Unpause Game with
Escape
Key:Add an
Escape
key check in yourUpdate()
function:csharp void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { if (gameIsPause) { unpauseGame(); // Unpause the game if it's already paused } else { // Existing code to pause the game pauseMenu.fadeUIIn(fadeTime); Time.timeScale = 0; gameIsPause = true; } } } <code></code>
These changes should address your issues. Let me know if you need further clarification or have more details to share! 😊
November 21, 2024 at 3:09 pm #16472TerenceKeymasterCan you show me your
UIManager
,SceneTransition
andSceneFader
scripts?November 20, 2024 at 10:49 pm #16466TerenceKeymasterTry adding this line to
SceneTransition
. That should fix it:private void OnTriggerEnter2D(Collider2D _other) { if (_other.CompareTag("Player")) { GameManager.Instance.transitionedFromScene = SceneManager.GetActiveScene().name; PlayerController.Instance.pState.cutscene = true; PlayerController.Instance.pState.invincible = true; if(UIManager.Instance.sceneFader == null) UIManager.Instance.sceneFader = UIManager.Instance.GetComponentInChildren<SceneFader>(); StartCoroutine(UIManager.Instance.sceneFader.FadeAndLoadScene(SceneFader.FadeDirection.In, transitionTo)); } }
The problem is likely that
UIManager
loads afterSceneTransition
, causingUIManager.Instance.sceneFader
to be null and breaking the sceneFader transition.November 20, 2024 at 12:47 pm #16455taiFormer PatronHere is the SceneFader.cs. It already changed to Awake when i downloaded it.
<code>using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class SceneFader : MonoBehaviour { public float fadeTime; private Image fadeOutUIImage; public enum FadeDirection { In, Out } // Start is called before the first frame update void Awake() { fadeOutUIImage = GetComponent<Image>(); } // Update is called once per frame void Update() { } public void CallFadeAndLoadScene(string _sceneToLoad) { StartCoroutine(FadeAndLoadScene(FadeDirection.In, _sceneToLoad)); } public IEnumerator Fade(FadeDirection _fadeDirection) { float _alpha = _fadeDirection == FadeDirection.Out ? 1 : 0; float _fadeEndValue = _fadeDirection == FadeDirection.Out ? 0 : 1; if(_fadeDirection == FadeDirection.Out) { while(_alpha >= _fadeEndValue) { SetColorImage(ref _alpha, _fadeDirection); yield return null; } fadeOutUIImage.enabled = false; } else { fadeOutUIImage.enabled = true; while (_alpha <= _fadeEndValue) { SetColorImage(ref _alpha, _fadeDirection); yield return null; } } } public IEnumerator FadeAndLoadScene(FadeDirection _fadeDirection, string _sceneToLoad) { fadeOutUIImage.enabled = true; yield return Fade(_fadeDirection); SceneManager.LoadScene(_sceneToLoad); } void SetColorImage(ref float _alpha, FadeDirection _fadeDirection) { fadeOutUIImage.color = new Color(fadeOutUIImage.color.r, fadeOutUIImage.color.g, fadeOutUIImage.color.b, _alpha); _alpha += 0.02f * (_fadeDirection == FadeDirection.Out ? -1 : 1); } } </code>
November 20, 2024 at 12:34 pm #16453TerenceKeymasterIf you are still working on the 9.5 files, try changing the
Start()
toAwake()
inSceneFader
and see if it fixes the issue. More information here: https://blog.terresquall.com/community/topic/part-5-article-changes-common-issues-bugfixes/November 20, 2024 at 11:04 am #16444TerenceKeymasterThat is strange. Try expanding the Cave_1 file in your Scene after loading the new level:
View post on imgur.com
I suspect the Scene is loading, but the Scene Fader isn’t deactivating so it looks like the scene isn’t loading.
November 19, 2024 at 1:05 pm #16416taiFormer PatronHi, i am trying out the Part 9.5 project files the project worked fine but all the ability is unlock so i delete all the save files in the folder
C:\Users\phamh\AppData\LocalLow\DefaultCompany\Metroidvania Tutorial
.View post on imgur.com
When i reload the project and open from Main Menu scene its normal but when i clicked Play the screen turned black and i can only hear sound in the background as in the video.
I have tried redownload the project files but its not working anymore.
November 9, 2024 at 3:03 am #16280In reply to: Scene Transitions Not Working
Ferral ChildParticipantOkay, I screen recorded and it captured something I didn’t notice is that the UI Manager, Canvas, and Scene Fader disappear when I play the game.
View post on imgur.com
Thank you for being so patient with me ;<;
November 8, 2024 at 8:30 pm #16277In reply to: Scene Transitions Not Working
Chloe LimModeratorOk, could you record a video of the scenefader game object inspector during play? Just play the scene and select the scenefader in the hierarchy
has upvoted this post. November 8, 2024 at 2:54 pm #16273In reply to: Scene Transitions Not Working
Chloe LimModeratorOk, in your recording it seems that your scenetransition script is failing to start the coroutine of the scene fading in the at start, which means that the UIManager is unable to find the scenefader to start the fade sequence, is the scenefader game object assigned in the inspector of your UIManager Script?
November 8, 2024 at 12:11 pm #16272In reply to: Scene Transitions Not Working
Ferral ChildParticipantI checked- Scene Transition, Start Point, UI Manager, Canvas, and Scene Fader are all enabled.
November 7, 2024 at 11:20 am #16268In reply to: Scene Transitions Not Working
Chloe LimModeratorOk, is your scenefader ui disabled in the hiearchy? need to enable it or there will be a null exception as the script cant find the inactive scenefader When your scene starts, there should be a fade out, then when moving to another scene it will fade in then out again to the new scene
has upvoted this post. - Ensure that
-
AuthorSearch Results
Advertisement below: