Answer the question
In order to leave comments, you need to log in
What is the best way to change interval with change?
I have several identical prefabs with initially the same properties, but along the way, some of the characteristics change, for example, a counter, I set such a counter
private float RegenerationSpeed = 2f;
void Start(){
InvokeRepeating("Regeneration", 0f, RegenerationSpeed);
}
private void CellRegeneration(){
++Counter;
}
private void SetRegeneration(float r){
RegenerationSpeed = r;
}
Answer the question
In order to leave comments, you need to log in
I would advise you to do everything with the timer not on the call, but on IEnumerator, everything is nowhere clearer:
IEnumerator test() //Создаёшь новый IEnumerator
{
//Внутри можешь писать код как в обычном методе
yield return new WaitForSeconds(<секунды>); //Ждёт нужное количество секунд
}
StartCoroutine(test(/*Ну и аргументы, если нужно*/));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question