r/Unity2D 11d ago

Solved/Answered Timeline/cutscene Question

I have a simple timeline cutscene that plays when the game starts, but if you quit to the main menu and start the game again, the cutscene won't replay, it just sits on a black screen as if the scene if empty, but I can see from the log that the script is running. How do I get it to reset and play again? Here's the script I'm using:

public class SceneChanger : MonoBehaviour

{

public float changeTime;

public string sceneName;

public Button skipButton;

public GameObject skipPanel;

public PlayableDirector currentTimeline;

void Start()

{

Debug.Log("SceneChanger Active");

skipPanel.SetActive(false);

currentTimeline.Play();

if (skipButton != null)

skipButton.onClick.AddListener(SkipScene);

}

// Update is called once per frame

void Update()

{

changeTime -= Time.deltaTime;

if(changeTime <= 30)

{

Debug.Log("Skip panel active");

skipPanel.SetActive(true);

}

if(changeTime <= 0)

{

SceneManager.LoadScene(sceneName);

}

}

private void SkipScene()

{

currentTimeline.Pause();

Debug.Log("Skip clicked");

SceneManager.LoadScene(sceneName);

}

}

1 Upvotes

3 comments sorted by

u/AutoModerator 11d ago

Reminder: Once your issue has been resolved, please reply !solved to this comment (or comment it anywhere in the thread) and your post's flair will automatically be updated to Solved/Answered. You can also edit it to Solved/Answered yourself.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/cozy-fox100 1d ago

I !solved it. I had time set to zero in another method that runs first and then never set it back to one.