can someone share with me a count up and countdown timer because i cant script for life
You’ll need to be a bit more specific about what you’re trying to do.
im trying to make a game thats like climbing platforms and stuff but i wanna show people how long they have bin playing for so i need a timer
Have you checked the wiki… I would wager there will be a timer script there. May not be 100% what you need, but will get you moving in the right direction.
Regards,
Matt.
sorry but i just registered an account on this website and i barely know anything wears the wiki?
using UnityEngine;
using System.Collections;
public class Counter : MonoBehaviour {
public float Amount; // How much to increment/decrement by
public float Wait; // Time to wait till increment/decrement
public float InitialCount; // What the start count is
public float Count; // The Current Count
void Start () {
Count = InitialCount; // Setting the start value
StartCoroutine(Run()); // Start the counting
}
IEnumerator Run () {
yield return new WaitForSeconds(Wait); // Wait for a set amount of seconds
Count += Amount; // Increment
StartCoroutine(Run()); // Re-Play
}
}
There you go, that’s a C# script that will set the count to a intitial value, add a certain amount, and will wait a certain amount of time before adding again.