Ambiera ForumDiscussions, Help and Support. |
|
[ 1 2 ] Page 2 of 2 |
|
|||||
|
Meant as support for @coa and emerged at the same time when he had found a solution himself posting anyway an additional alternative also counting the CopperCube variable "time" by adjustable count rate in milliseconds plus you can set an initial value from where to start to count: /* |
||||
|
thanks again Hadoken I learned alot about making behaviors making this feature |
||||
|
Hi, I don't think this solution will really work with lag. In fact, I don't also think that seconds are the real seconds here:) I believe, onAnimate function is executed on screen draw, which in normal case happens every ~17 ms. Check this part: if(this.now > this.endTime) So let's say we start at 0 ms for simplicity (even though it's actually int representation of the current local time): 1. On the first run this.now is 0 and the code is not executed 2. On the second run it's 17 and nothing happens still 3. On 60th run it's 1020 ms, and now it enters the if block. On the last line of it, we're adding another countRate value (which is 1000) and get 2020ms - so our second is shifted by 20 ms in the first loop. If expect a precise second to count - condition should be "this.now === this.endTime". If you lag, which means your framerate drops, or run 30 fps this shift will increase even more. From the other hand, if your application froze for 1000 ms this second will be lost from the counter because of this.now + this.countRate_ms. You can easily test this by alttabing from game and alttab back then. I guess, on the last line you should do this.endTime += this.CountRate_Ms; Or why not to use a built in timer, by just assigning the difference between game start and current time in seconds to some variable, like: behavior_timer = function () { |
||||
|
|
||||
|
can anyone tell what the "0.62" do in this snippet from @hadoken? What's the main difference between hadokens 1st code compaired to the latest version above (also from hadokens)? I got good results with a custom version of this one, not sure tho how they differ... Thanks in advance. hadoken wrote:
this one should do the job: /* |
||||
|
@gree under normal circumstances in the given example by multiplying delta time (this.DeltaTime) by an extra 0.062 you get a nice value of about 1 for good use regarding fps and counter increase ... think that's all |
||||
|
@hadoken thanks for the note. I've used some bits and bites from your script. It kinda works for me. Thanks again. Without I would have been lost :) |
||||
|
@hadoken just to clear things up a little bit for myself; the "extra 0.062"....speaking of "exact" this is like "non-exact" by 0.062ms? So, this way the time orients to be as close to a frame; but the timing isn't correct anymore; because it's shifted by 0.062ms? I'd rather prefer exact timing than any frame relationship. Or is this "relation" needed? I'm also having troubles outputting multiple-Deltatimes as 'sum' within the console.log. It "print" outputs correct; but in he console.log I'm getting 'NAN'. Example: works in console.log + print: this.counter = this.DeltaTime/100; does work in print output but not in console.log: this.counter += this.DeltaTime/100; any idea why this reacts kinda weird? Thanks. |
[ 1 2 ] Page 2 of 2 |
|