EDIT: NEVERMIND, I JUST DIDN’T SEE THAT I PUT TIME.TIMESCALE = 0 IN MY SCRIPT, SORRY
so when i die in my game, i have a death menu where if you play “play again”, it will reload the level, for some reason, when i try it, it doesnt work
i have a scene transition/level loader script
here it is
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelLoader : MonoBehaviour
{
public Animator transition;
public float transitionTime = 1f;
// Update is called once per frame
void Update()
{
if(Input.GetMouseButtonDown(0))
{
//LoadLevel("Maze1");
}
}
public void LoadLevel(string levelToLoad)
{
StartCoroutine(LoadLevelCoroutine(levelToLoad));
}
public IEnumerator LoadLevelCoroutine(string levelName)
{
//Play animation
Debug.Log("Begin load animation");
transition.SetTrigger("Start");
//Wait for animation to stop playing
Debug.Log("Waiting");
yield return new WaitForSeconds(transitionTime);
Debug.Log("Done waiting");
//Load scene
Debug.Log("Loading scene");
SceneManager.LoadScene(levelName);
}
}
When you say it doesn’t work. What doesn’t work? Does the coroutine never start? Do you see all your debug messages? You have a lot in there, which is great for debugging, but you didn’t mention if they run or not.
everything works in the coroutine and it debugs “waiting” but it doesnt debug “done waiting” and change the scene
so its something wrong with the wait i think
the button press works so im pretty sure the event system is in the scene
i did not set time.timescale, i just disable player movement by setting a boolean to false, i cant use time.timescale or else scene transitions wont work
No, it’s specifically referring to your comment here:
This led you to think “oh it can’t be timescale because my scene transitions work fine,” and then you realize “oh it WAS timescale, and the scene transitions continued working fine anyway (for whatever reason).”
This type of “wait… how did this ever work?!” question comes up ALL THE TIME when you’re working with big systems. Stuff works and in your mind you think “Oh it is working because of X…” and then one day you notice that you never actually put X into your program at all, and suddenly you blink and think “Wait, what is making this work?!”
All the time. Happens ALL the time. We are all human and we are HORRIBLE at reasoning about stuff like this, and the computer is ultra stupid and just mindlessly does what it is told, and when it works we go “Cool, I fixed it!” when it was actually because something else changed.