C
C
Chalaiyev2021-01-05 23:28:22
C++ / C#
Chalaiyev, 2021-01-05 23:28:22

How to do something 1 time in Update?

I want to make my game, for example, increase the difficulty every 2 minutes, but I could not find on the Internet how to work with time in this way, and therefore I wrote my code like this:

private void FixedUpdate() 
    {
        StartTime += 0.1f * Time.deltaTime;
        if (StartTime >= EndTime)
            spawnRate--;
    }


but it only works in Update, and therefore it happens not once, but a lot, how can I fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2021-01-06
@freeExec

Counting in FixedUpdate Time.deltaTimeyou get nonsense.

so it doesn't happen once, but many times

And who will install the next one EndTime?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question