| We hope you enjoy your visit. You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you are already a member please log in to your account to access all of our features: |
- Pages:
- 1
- 2
| Delta time for complex operations; How to? | |
|---|---|
| Tweet Topic Started: Aug 31 2010, 07:42 PM (722 Views) | |
| Eansis | Aug 31 2010, 07:42 PM Post #1 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I'm trying to get delta time to work. I made a script called MoveExt which is the same as Move except it looks like this: x+=(sin(argument1...*argument2+argument3)/global.DELTA y+=(cos(argument1...*argument2+argument4)/global.DELTA z-=(sin(argument0...*argument2-argument5)/global.DELTA I call it like this MoveExt(rotx,roty,SPEED,0,0,grav); grav-=global.GRAVITY; Step(); Well it does not work. It is not a problem of lag...I test this on fixed frame rates and the results are totally different. By the way global.DELTA is called in the step event, global.DELTA=fps/60. The problem is the object follows different paths depending on frame rates, I'm trying to get it to follow the same trajectory regardless of frame rate. |
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY
| |
![]() |
|
| Koning Stoma | Aug 31 2010, 07:47 PM Post #2 |
|
Elite Member
![]() ![]() ![]() ![]() ![]() ![]()
|
Do you change the speed while testing? Do you use acceleration / friction? |
![]() |
|
| Eansis | Aug 31 2010, 07:58 PM Post #3 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
No, the frame rate is constant and so is global.GRAVITY. |
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY
| |
![]() |
|
| skarik | Aug 31 2010, 09:06 PM Post #4 |
|
kitten eating scum
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
acceleration due to gravity is a 2nd degree function. multiply gravity by delta time. delta time is not fps/60, it should be 60/fps. test fps first so you don't get divide by zero. you can do this by limiting the lower value of fps in a max(...) call. also, it's multiply by delta time on your move script. also, you should really compute delta time so that you are in units per second, not units per step. also, don't use fps. it is not updated fast enough to give you a good result. also, don't use current_time, same thing there. use Yourself's high resolution timer or, if that's too complicated, you all are welcome to 'decompile' stickman and take the S-Timer wrapping. of course, just don't claim stimer.dll as your own because that thing took me a couple days |
| Blog|EHS | |
![]() |
|
| Eansis | Aug 31 2010, 09:51 PM Post #5 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
All your doing is flipping the equations around...won't change anything. I already compensated for division by zero by putting "if global.DELTA=0 global.DELTA=0.1;" Your gravity idea is a good suggestion, but it is one I already tried and did not work. Your suggestion was, instead of: MoveExt(rotx,roty,SPEED,0,0,grav) grav-=global.GRAVITY; to seperate them like: grav-=global.GRAVITY/global.DELTA z+=grav; tried both already neither works. Anyway I've chucked the idea of delta time and am using a sort of integrated frame skip instead. Only problem is I'm having a lag when doing the frame skip because the fps variable does not update fast enough. I tried using Yourself's but it gave me the same lag, maybe I'm doing something wrong? It works something like this: global.DELTA=fps global.SKIP=3 if (global.DELTA<1) global.DELTA=1; if can_marker=1 {marker=hrt_time_now(); can_marker=0;} global.FORCE=hrt_time_now()-marker; if (global.DELTA>55 or global.FORCE>global.SKIP) {u3d_draw(); can_marker=1} but I can't figure out what Hrt function to replace fps with, and I have a feeling I'm not define global.FORCE right either... If the problem is Yourself's Dll, I would very much like to use your Stimer.dll, if you'll let me. I can send you the file if you want. Also there was a quote from this recent GMC topic but it's confusing and I don't really know how to go about it:
http://gmc.yoyogames.com/index.php?showtopic=484449&st=0&p=3589991&hl=+high%20+res%20+timer&fromsearch=1&#entry3589991 |
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY
| |
![]() |
|
| skarik | Aug 31 2010, 11:36 PM Post #6 |
|
kitten eating scum
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I'm promoting common practice. For that code, if you really want to know it's taking the average of a set of 16 numbers, 15 of them are the last calculated FPS and 1 one them is the current FPS. |
| Blog|EHS | |
![]() |
|
| Eansis | Sep 1 2010, 12:19 AM Post #7 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Still totally confused lol...Koning Stoma said he got Yourself's DLL to work...Koning where are you Stoma?
|
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY
| |
![]() |
|
| skarik | Sep 1 2010, 02:12 AM Post #8 |
|
kitten eating scum
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I used Yourself's timer on Ruins, and you know how long ago that was. It can't be that hard. Just use the unit per second scale so you don't have to do any timer setting. The global.DELTA will literally be
And if that doesn't work...
|
![]() |
|
| Eansis | Sep 1 2010, 03:06 AM Post #9 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Can't get it to work...Just to clarify I'm not looking for delta time anymore, just frameskip. So what I'm looking for is a replacement for the fps variable, that's it. instead of global.delta=fps; global.delta=some variable |
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY
| |
![]() |
|
| skarik | Sep 1 2010, 04:05 AM Post #10 |
|
kitten eating scum
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Can't help ya. Last time I did frame skip was with this. It didn't work. The fps variable value increased, but the frames rendered per second stayed the same. It's not going to work, I'm going to tell you now. |
![]() |
|
| Eansis | Sep 1 2010, 05:10 AM Post #11 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
ooo I've kind of gotten it to work! |
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY
| |
![]() |
|
| Koning Stoma | Sep 1 2010, 09:40 AM Post #12 |
|
Elite Member
![]() ![]() ![]() ![]() ![]() ![]()
|
This is how I did it: In the create event of some controlling object: hrt_set_resolution(1000); marker=hrt_marker_add(); In the begin step event: marker_delta=hrt_marker_delta(marker); if fps != 0 global.fpsfactor=marker_delta/25; hrt_marker_set(marker, 0, 0); This way it will give the factor compared to 40 fps. 1000/40 = 25. Then when you move an object you multiply the speed while moving it like this: Move(0,roty,speed*global.fpsfactor); While accelerating or decelerating "speed" you should multiply the factor by global.fpsfactor like this every step before changing the speed: speedadd=(.6*global.fpsfactor); fric=.3*global.fpsfactor; |
![]() |
|
| Eansis | Sep 1 2010, 06:01 PM Post #13 |
|
ghost
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
The method I used doesn't require you to change any object's speed at all, and works on the slowest computer I could find (so far)...finding a slow computer to test it on is so hard these days
|
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY
| |
![]() |
|
| Koning Stoma | Sep 1 2010, 08:51 PM Post #14 |
|
Elite Member
![]() ![]() ![]() ![]() ![]() ![]()
|
Whats your method? |
![]() |
|
| luenardi | Sep 1 2010, 09:37 PM Post #15 |
|
Cofee Machines Rock
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Yeah... i'm wondering too.. :offtopic Riekyrr seems to be online but not answering his skype.. I hope he's ok. Edited by luenardi, Sep 1 2010, 09:38 PM.
|
![]() For your perception no. But my universe has no such limits. www.recall.co.nr | |
![]() |
|
| Go to Next Page | |
| « Previous Topic · Off-topic · Next Topic » |
- Pages:
- 1
- 2





![]](http://z1.ifrm.com/static/1/pip_r.png)





10:49 AM Jul 11