Hello everyone
I have been searching and tried almost everything that i could find but none of them has been worked.
I cannot let my timer stop after my player collides with objects, walls or something else. All of items have rigidbody2d and box collider 2d. Is trigger off because otherwise the player passes away from those objects.
I would be grateful if you could help.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Timer : MonoBehaviour
{
public Text counterText;
public bool TimerOn;
public float seconds, minutes;
void Start()
{
TimerOn = false;
Text counterText = GetComponent<Text>();
counterText = GetComponent<Text>() as Text;
}
void Update()
{
if (TimerOn = true)
{
seconds = (int)(Time.time % 60f);
counterText.text = seconds.ToString("0");
}
}
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == "Player")
{
TimerOn = false;
}
}
}