Welcome Guest [Log In] [Register]
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:

Username:   Password:
Add Reply
Delta time for complex operations; How to?
Topic Started: Aug 31 2010, 07:42 PM (724 Views)
Eansis
Member Avatar
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

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
Koning Stoma
Member Avatar
Elite Member
[ *  *  *  * ]
Do you change the speed while testing? Do you use acceleration / friction?
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
Koning Stoma
Aug 31 2010, 07:47 PM
Do you change the speed while testing? Do you use acceleration / friction?
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

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
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
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
Synexn-Prime
Aug 31 2010, 09:06 PM
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
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:

Quote:
 
You can also use a movement function against the FPS to slowly move the game speed up and down. A movement function is like this:

ft = (ft-1 * y + x) / (y + 1)

where "y" is how slow you want the movement to carry for, and "x" is the current value ('fps' in this case) that you want to narrow. So for your needs, I would do this:

//initialize
narrow_fps = room_speed;


//every step, or alarm, whenever
narrow_fps = (narrow_fps * 15 + fps) / 16;


That will make it so that you don't go jumping from fast to slow constantly at least. Not as precise as some functions, but it's a quick fix.

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

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
Quote:
 
All your doing is flipping the equations around...

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
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
Synexn-Prime
Aug 31 2010, 11:36 PM
Quote:
 
All your doing is flipping the equations around...

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.
Still totally confused lol...Koning Stoma said he got Yourself's DLL to work...Koning where are you Stoma? :D
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
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
Code:
 
current_frame_time = hrt_grab_time(); // Or whatever it is called
global.DELTA = (current_frame_time - last_frame_time) / 1000.0;
last_frame_time = current_frame_time;


And if that doesn't work...
Code:
 
current_frame_time = hrt_grab_time(); // Or whatever it is called
global.DELTA = (current_frame_time - last_frame_time) / hrt_get_resolution(); // or whatever it's called
last_frame_time = current_frame_time;
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
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

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
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.
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
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

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
Koning Stoma
Member Avatar
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;
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
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 :lol:
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
Koning Stoma
Member Avatar
Elite Member
[ *  *  *  * ]
Whats your method?
Offline Profile Quote Post Goto Top
 
luenardi
Member Avatar
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.
Posted Image

For your perception no.
But my universe has no such limits.


www.recall.co.nr
Offline Profile Quote Post Goto Top
 
ZetaBoards - Free Forum Hosting
Fully Featured & Customizable Free Forums
Learn More · Sign-up Now
Go to Next Page
« Previous Topic · Off-topic · Next Topic »
Add Reply