user11102212
user11102212

Reputation: 31

How do you change the frequency of the update function in unity?

I'm programming a boss fight in unity, and am currently testing how well the boss bar works. With the way I have written my code, it means every time I test it, I have to run the entire boss fight. Is there a way to speed up the run mode so I can get through it faster?

Upvotes: 1

Views: 735

Answers (3)

Fattie
Fattie

Reputation: 12336

It's a good question, there's no really good way to do that.

Part of working on games is, you need to build-in "development logic" that will let you "automatically win" battles and so on for exactly this reason.

It's actually a huge fairly major part of making games!

  • A quick fix is, just have a dev setting where the boss has much lower strength (or whatever) so you can kill it instantly. That's one approach.

It's extremely hard to "test" these things without "actually testing" them!

Upvotes: 1

Daruden
Daruden

Reputation: 149

You could create triggers for when you want something to happen or change a condition

public bool TestMode; 

void Update(){
    #region Tests
    if(TestMode){
      if (Input.GetKeyDown("a"))
      {
        bossLife -= 10;
      }
      if (Input.GetKeyDown("b"))
      {
        bossIsEnraged = true;
      }

      if (Input.GetKeyDown("c"))
      {
        bossIsDead = true;
      }

    }
   #endregion
}

Upvotes: 0

BrightenedLight
BrightenedLight

Reputation: 333

You can try adjusting Time.timescale higher than one, this will accelerate your game.

https://docs.unity3d.com/ScriptReference/Time-timeScale.html https://answers.unity.com/questions/239552/accelerating-time-dramatically.html

Upvotes: 1

Related Questions