What I have:
using UnityEngine;
using System.Collections;
public class Locked : MonoBehaviour
{
void Update(){
float seconds = Time.time;
bool s= seconds % 2==0;
renderer.enabled= s;
}
void Main(){
renderer.enabled= Start.Locked;
}
}
Start.Locked:
public static bool Locked;
Basically, I want the object to have its render enabled for like 5 seconds, but I have no idea how to do this… please help
THANKS!!
C# co-routines should be able do this quite easily.
public IEnumerator MyCoroutine(Object value)
{
// Do some things
yield return new WaitForSeconds(5);
// Do some more things 5 seconds later
}
To start a coroutine use the MonoBehaviour.StartCoroutine(MethodName, ArgValue) Method.
http://docs.unity3d.com/Documentation/ScriptReference/index.Writing_Scripts_in_Csharp_26_Boo.html
Basic timer implementation not calling the expensive Co-routines or Invoke
float timer;
int waitingTime;
void Update(){
timer += Time.deltaTime;
if(timer > waitingTime){
//Action
timer = 0;
}
}
Does some actions every waitingTime seconds.