I have something wrong with my Parkour game with the timer. and I want it to stop when I press the R
key, this is the code and I hope that someone can help me.
Cannot implicitly convert type ‘string’ to ‘float’
thanks
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
public class Timer : MonoBehaviour
{
[Header("Component")]
public TextMeshProUGUI TimerText;
private float stopTime;
[Header("Timer Settings")]
public float currentTime;
public bool countDown;
private bool isRunning = false;
// Start is called before the first frame update
void Start()
{
isRunning = true;
}
// Update is called once per frame
void Update()
{
currentTime = countDown ? currentTime -= Time.deltaTime : currentTime += Time.deltaTime;
TimerText.text = currentTime.ToString();
}
public void TimerReset()
{
if (Input.GetKeyDown(KeyCode.R));
{
print("RESET");
stopTime = 0;
currentTime = "00";
isRunning = false;
}
}
}