In the update, I have set up a counter so that after 140 frames, Unity will quit the game. But this quit command doesn't quit and it just continues to play the game. What am I doing wrong? I am using and testing in Unity 2D. There are no errors and all the prints are visible.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Normal_Car : MonoBehaviour
{
private int counter = 0;
public Vector3 finalPos = new Vector3(0.00f,0.00f,0.00f);
public Transform t;
// Start is called before the first frame update
void Start()
{
t.GetComponent<Transform>();
}
// Update is called once per frame
void Update()
{
print("Frame: " + counter.ToString());
counter += 1;
t.position += finalPos;
if(counter >= 140)
{
Application.Quit();
print("Quit!");
}
}
}