How can I teleport the player when a bonus level timer runs out?
I'm making a FPS with a bonus level system with a timer. How can I teleport the timer ends? Here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Timer : MonoBehaviour
{
float currentTime = 0f;
float startingTime = 60f;
[SerializeField] Text countdownText;
// Start is called before the first frame update
void Start()
{
currentTime = startingTime;
}
// Update is called once per frame
void Update()
{
currentTime -= 1 * Time.deltaTime;
countdownText.text = currentTime.ToString("0");
if (currentTime <= 0f)
{
currentTime = 0f;
}
if (currentTime <= 5)
{
countdownText.color = Color.red;
}
}
}
I thought I could do something like this:
if (currentTime = 0)
{
// TeleportPlayer.sceneName or something
}
Please help me, I have no knowledge of C#!
Comment