Update function functionality

Can someone explain to me why my update function seems to be calling everything 6 times per frame when I first start the game?
https://playcanvas.com/editor/scene/581391

Your project has many scripts. You should point us more specifically to what script contains the update function.

Right, sorry. I wasn’t sure if it was necessarily something in the update function itself or something else interacting with it, but here’s the script with the update function.
https://playcanvas.com/editor/code/529780?tabs=10861152,10800992,10964296

the link doesn’t open a specific file but the editor with more files opened. And shows WinCheck.js that doesn’t have an update function.

Anyway… 6 update functions make me think that you attached the script to each dice. Can it be?

nope… you have 5 dices :slight_smile:

Yep, this was my first thought as well, that maybe the function calls were getting caught in the for loops

As for the link not going to the specific file, it may be because I am still working with the scripts. The one with the update check is the checkWin.js.

I suppose you mean checkRoll.js
And it doesn’t seem that the update can be called 6 times per frame. Are you sure? How did you determine this?

Yes, sorry again. I did mean checkRoll.js, and if you remove the * 6 from this.timer += dt * 6;, the timer gets logged 6 times per tick. This may not mean its being called 6 times per frame, I have very little understanding as to how delta time actually works, but this seemed like to much of a coincidence for it to be anything else.

Huh…I put the check function in a while loop, and no more multi check?

It represents the time passed between last 2 frames. At an average of 30 fps its value is about 1/30 = 0.3333

So i would imagine 60 fps is somewhere around 0.16

Yes it’s correct. :slight_smile: