i'm currently using this (C#)
void FixedUpdate ()
{
TIME++;
}
how can i change this so it adds 0.06 every second, rather than adding at the rate of the physics timestep?
i'm currently using this (C#)
void FixedUpdate ()
{
TIME++;
}
how can i change this so it adds 0.06 every second, rather than adding at the rate of the physics timestep?
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.InvokeRepeating.html
TIME is a terrible name for a variable that increments by .06 every second. Also, all caps is not a convention that anyone uses for variables.
using UnityEngine;
public class Whatever : MonoBehaviour {
[SerializeField] float addToWhateverEverySecond = .06F;
float whatever;
void Start () {
InvokeRepeating("AddToWhatever", 0, 1);
}
void AddToWhatever () {
whatever += addToWhateverEverySecond;
}
}
That said, I don't actually think you're asking for what you asked for. I think you're trying to do this:
using UnityEngine;
using System.Collections;
public class Whatever : MonoBehaviour {
[SerializeField] float delay = .06F;
float whatever;
IEnumerator Start () {
while (true) {
yield return new WaitForSeconds(delay);
whatever += delay;
}
}
}
http://unity3d.com/support/documentation/ScriptReference/index.Coroutines_26_Yield.html