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

Discussion in 'Scripting' started by xaviergamerpro9, Jul 11, 2020.

  1. xaviergamerpro9

    xaviergamerpro9

    Joined:
    Jul 10, 2020
    Posts:
    12
    I am trying to make it so every 2 minutes the player loses control of their character.
    So far I have an if statement that checks a boolean before letting the player move but I do not know how to change that boolean to false every 2 minutes.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,735
    Create a float variable to keep track of the time. Every update, add Time.deltaTime to it. Once the value is >= 120, make the player lose control.
     
    Last edited: Jul 11, 2020
    Kurt-Dekker likes this.
  3. xaviergamerpro9

    xaviergamerpro9

    Joined:
    Jul 10, 2020
    Posts:
    12