Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Timer to change scene after click

Discussion in 'Scripting' started by matstacy, Feb 13, 2020.

  1. matstacy

    matstacy

    Joined:
    Dec 10, 2019
    Posts:
    15
    I'm trying to have my scene change after 10seconds. but i want the timer to only start when the user presses the screen. any help would be great thankyou
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @matstacy

    Can you show your current code? Or which part you have a problem with?

    Or are you just asking for a bespoke solution to avoid little bit of googling?

    Try searching for these and you'll find several examples here and in YouTube (for example):
    - Unity register touch
    - Unity timer
    - Unity change scene
     
  3. matstacy

    matstacy

    Joined:
    Dec 10, 2019
    Posts:
    15
    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.UI;
    6.  
    7. public class Score : MonoBehaviour
    8. {
    9.  
    10.     public Text scoreText;
    11.     public int score;
    12.     // Start is called before the first frame update
    13.     void Start()
    14.     {
    15.      
    16.     }
    17.  
    18.     // Update is called once per frame
    19.     void Update()
    20.     {
    21.         scoreText.text = "Clicks" + score;
    22.  
    23.         if (Input.GetMouseButtonDown(0))
    24.         {
    25.             score++;
    26.         }
    27.     }
    28. }
    29.  
    that is the current code i have that counts clicks as a score. i want a timer to start after the first click only
     
  4. matstacy

    matstacy

    Joined:
    Dec 10, 2019
    Posts:
    15
    And no if you could see my history lol. google and youtube i have spent hours trying to find it. i can get the scene to change after the time i want. but the time will start as soon as scene loads. thats where im stuck
     
  5. Serinx

    Serinx

    Joined:
    Mar 31, 2014
    Posts:
    785