Timers!

Report any bugs here

Timers!

Postby phsc » 9 March 2019, 21:16

well this is pretty simple

i am trying to get the average character speed and the average door speed

and i am doing experiments
this is the area im trying to calculate teh speed it takes, it is ocmposed of lovely 50 blocks, that would be 500 units in pb2


so i set up a timer that activates every second(value of 30), one every second/10(value of 3), and one every second/100(value of 0.3)
and guess


i am not sure how it works exactly but that makes no sense, or i am missing something really big

60 - 10 39 - 7 could make some sense but then 60/10 is 6 while 39/7 is 5.5 so in theory that means 1.55 seconds or something? im unsure? because it still makes no sense considering 300 = 10 s and 30 = 1 s and thus 3 = 0.1s?

anyway, so i decided id change the second/100(0.3) to 1 and then divide it by 3 when it reaches the end to see if there is actually a difference, AND THERE IS


even on same testings there is a small difference, i achieved the value of 1.65 seconds as the time for a player already at max speed to go trough 50 level editor blocks because of the variations



in this case i changed s(30) to s(0.3) to compare with them, it makes no sense at all



so i decided i was going to do one more test


the order in which it shows is, var_timea, then var_timeb, then var_timec

1 activation:

2 activation:


just going to leave this here, if someone is going to tell me i need to work with 60 as the value cuz its time, no, its seconds, it shouldnt matter, its not minutes, and even then 0.1 minutes is a thing which is 6 seconds and even then it doesnt make any sense

BUT I RAN IT AGAIN




my game is fully on high, with stable fps which is 60

eric my lord please tell me what is wrong
or anyone else
User avatar
phsc
Phoenix Falkok [450]
 
Posts: 453
Joined: 27 July 2013, 13:58
Location: Ancapistan

Re: Timers!

Postby phsc » 13 March 2019, 00:36

Literally bump.

I need to write more though
User avatar
phsc
Phoenix Falkok [450]
 
Posts: 453
Joined: 27 July 2013, 13:58
Location: Ancapistan

Re: Timers!

Postby Eric Gurt » 13 March 2019, 09:20

I believe in order to measure speed you have to compare position in last frame and current frame by X and Y. Then just divide by GSPEED which is internal value that keeps game speed multiplier on each frame. In order to make this as accurate as possible you need one infinite timer with 0 delay (so it is called on each frame and works with all GSPEED values).

Delta time multiplier can be extracted to variable (should have something like GSPEED in trigger action description).

In the result you will have something like this:
speedX = ( newX - oldX ) / GSPEED
speedY = ( newY - oldY ) / GSPEED
speed_dist = sqrt( speedX * speedX + speedY * speedY )

PS: Not sure what exactly might not work in your code, but by their nature, timers are not executed more than 1 time per frame - I believe some of problems might some from there. If what I've shown is not what needed maybe you can provide map ID?
Work it harder
Make it better
Do it faster
Makes us stronger
More than ever hour
After our work is never over.
User avatar
Eric Gurt
PB2 Developer
 
Posts: 241
Joined: 14 July 2013, 16:46
Location: dn.ua


Return to Bug Reporting

Who is online

Users browsing this forum: No registered users