r/Unity2D • u/cozy-fox100 • 2d ago
Question/Help 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
u/OrneryComplex6265 1d ago
I’d try stopping the director and resetting its time to zero before calling Play. also check that the timeline object isn’t surviving the scene change somehow
•
u/AutoModerator 2d 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.