Hello!
So I am trying to implement a “Skip-Button” in my 2D Platformer that does appear after a certain amount of minutes. Problem I have is that as soon as the player dies the “timer” resets.
So lets say I set it to 10 seconds, then if I die on second 8 it restarts at 0.
How would I be able to fix that?
It should only reset when the scene changes (switching from one level to the next one).
Here’s my Code so far: Note: the 3 second timer is just for testing purposes, it will be like 5 Minutes later on.
Thank you in advance!
[SerializeField] private GameObject skipLevelButton;
private void Start()
{
skipLevelButton.SetActive(false);
Invoke("ShowSkipButton", 3f);
}
private void ShowSkipButton()
{
skipLevelButton.SetActive(true);
}
public void HideSkipButton()
{
skipLevelButton.SetActive(false);
}
public void SkipLevel()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}