|
kTecH
|
 |
« on: July 09, 2008, 06:51:19 AM » |
|
Hi folks I've got strange problems with the AccurateTimeElapsed... So I know that if I want to move some objects with the same speed on every framerate/machine i must do for example: player.X := player.X + player.SPEED * TV.AccurateTimeElapsed but i don't understand why such movement on 60fps is normal and on les fps the player moves much slower. Bevor I forget- the SmoothTime is enabled and with the value 10. How can this be? The object I move should move same speed but with this well knowen "jumps" (sorry don't know how to describe this Iam not english;) )
please help!
|
|
|
|
« Last Edit: July 09, 2008, 07:26:04 AM by kTecH »
|
Logged
|
|
|
|
|
Shadowsong
|
 |
« Reply #1 on: July 09, 2008, 09:07:39 AM » |
|
Using the TimeElapsed function basically makes faster machines not playing faster than slower ones. If the machine doesn't reach 60 (or whatever VSync or not you have), it won't be able to render as fast. I can't explain it, but I can tell you that it is the same with my applications.
Trying to explain the effect a bit clearer:
A box moves from A to B with Timeelapsed. You run this on a 60 FPS or higher machine and on one with like 20 FPS. You would expect both boxes reaching B at the same time, while the "fast" box moves smoothly and the "slow" box jumps. However, they don't reach B at the same time, the machine with the less FPS is a bit slower. I can't explain why but that's how it happens.
|
|
|
|
« Last Edit: July 09, 2008, 10:04:04 AM by Shadowsong »
|
Logged
|
|
|
|
|
kTecH
|
 |
« Reply #2 on: July 09, 2008, 09:41:19 AM » |
|
any solutions? 
|
|
|
|
|
Logged
|
|
|
|
likedonuts
Customers
Community Member
    
Posts: 246
Diesel connoisseur
|
 |
« Reply #3 on: July 09, 2008, 12:57:38 PM » |
|
can you post the code?
|
|
|
|
|
Logged
|
information is not wisdom, wisdom is not knowledge, knowledge is not truth, truth is not beauty, beauty is not love, love is not music, music is the best - Frank Zappa
|
|
|
|
kTecH
|
 |
« Reply #4 on: July 10, 2008, 07:49:04 AM » |
|
sure but it is not more than i wrote before I ve got some functions like this: procedure addV(var Number,add:single); begin Number := Number + add*ftime; end; so when i likke to move the player i have such a code: if keyL then addV(player.v.x,player.speed); in the main loop I've got: ftime:=TV.AccurateTimeElapsed; and the initialization: TV.EnableSmoothTime(True, 10);
|
|
|
|
|
Logged
|
|
|
|
|
kTecH
|
 |
« Reply #5 on: July 10, 2008, 09:18:40 AM » |
|
or maybe sombody knows how to make such "low frame jumps" like in other games fE Quake if we have over 60FPS every thing is smooth if the fps counter is <10 then the carakter makes "jumps" so he do not moves 5cm per frame (like having 60 fps) he is moving every frame 50cm(when we have 6 frames) or do i understand this system wrong?
|
|
|
|
|
Logged
|
|
|
|
|
kTecH
|
 |
« Reply #6 on: July 11, 2008, 03:46:44 AM » |
|
Maybe I use something wrong for example AccurateTimeElapsed or TimeElapsed ??
|
|
|
|
|
Logged
|
|
|
|
ownage
Community Member

Posts: 16
|
 |
« Reply #7 on: July 11, 2008, 07:30:44 AM » |
|
If you used ftime = accuratetimeelapsed then instead of:
player.X := player.X + player.SPEED * TV.AccurateTimeElapsed
It should be
player.X := player.X + player.SPEED * ftime
Now aswell, i'm not sure if this is the problem, buti think you might need to put brackets like this.
player.X := player.X + (player.SPEED * ftime)
I always use tvengine.timeelapsed, and i can only guess that that difference between the two is that one is more accurate, but give it a try with timeelapsed if you still cannot get it to work.
|
|
|
|
|
Logged
|
|
|
|
AriusEso
Customers
Community Member
    
Posts: 375
Esoteric
|
 |
« Reply #8 on: July 11, 2008, 07:37:08 AM » |
|
Maybe I use something wrong for example AccurateTimeElapsed or TimeElapsed ?? Both of those functions are the same. They used to be different, but they are not anymore. They both return AccurateTimeElapsed now.
|
|
|
|
|
Logged
|
|
|
|
|
kTecH
|
 |
« Reply #9 on: July 14, 2008, 06:06:22 AM » |
|
ok so AccurateTimeElapsed and TimeElapsed are the same but... any solution for my problem??
|
|
|
|
|
Logged
|
|
|
|
|
newborn
|
 |
« Reply #10 on: July 14, 2008, 11:48:08 AM » |
|
TimeElapsed will return the time (in miliseconds) since last rendering pass.
So, if it took 10 seconds, TimeElapsed returned will be 10,000 If it took 1 second, TimeElapsed = 1,000
To move your character at a constant speed, use:
characterPosition += TimeElapsed * characterSpeed
Lets say we have this: characterPosition = 3 characterSpeed = 0.001
And for instance, it took 10 seconds since last rendering pass (hard drive was loading or computer lagged): TimeElapsed = 10,000, we get: position = 3 + (10,000 * 0.001) = 13
If last render was 1 second away, then: TimeElapsed = 1,000, we get: position = 3 + (1,000 * 0.001) = 4
As Shadowsong mentionned, if you enable VSync, then it will be capped at 60
Quite simple, no?
|
|
|
|
|
Logged
|
|
|
|
|
Shadowsong
|
 |
« Reply #11 on: July 15, 2008, 01:28:29 AM » |
|
Just to stay clear, VSync limits the framerate to the framerate of the used monitor. This is in most cases 60 or 75 as most monitors have 75 Hz (were Hz is frame/second). The mystery is, it theoretically is as newborn explained but it doesn't behave like this in reality. I go with newborn's example: characterPosition = 3 characterSpeed = 0.001 SHOULD BE:TimeElapsed = 1,000 -> newposition = 3 + (1,000 * 0.001) = 4 TimeElapsed = 20,000 -> newposition = 3 + (20,000 * 0.001) = 23 SOMEHOW HAPPENS:TimeElapsed = 1,000 -> newposition = 3 + (1,000 * 0.001) = 4 TimeElapsed = 20,000 -> newposition = 3 + (20,000 * 0.001) < 23 -> "slower" PC can't keep track to the good one And something else I experience, if you have VSync disabled and you get like 2000 FPS then everything becomes faster! Though it should not be faster than with 60 FPS but it is. I would like someone who knows what's going on inside there (Sylvain?  ) to explain why it sometimes moves slower or faster though you use TimeElapsed properly.
|
|
|
|
|
Logged
|
|
|
|
|
kTecH
|
 |
« Reply #12 on: July 15, 2008, 08:55:33 AM » |
|
Thx for answers @darkshadow - well it should be so simple but somehow it is not Now I render everything only when my fps count is > then 50 (I locked the fps on 60Fps) - now I don't have any problems with the simulation but well this is not a perfect solution 
|
|
|
|
|
Logged
|
|
|
|
jviper
Community Member

Posts: 1316
Discipline in training
|
 |
« Reply #13 on: July 21, 2008, 10:47:58 AM » |
|
Keep in mind, the AccurateTimeEllapse is the time in milliseconds. I usually convert that to seconds so that my speeds will be in terms of units/second. Either way, you should never confuse that with units/frame. They are not related. Also want to point out that AccurtateTimeEllapse returns the time from the last frame rendered, but then it does not update until the next frame is rendered. So if you call AccruateTimeEllapsed after the frame was rendered, but then somthing weird happens that delays you from using it, it will through the timing off. Somthing else that could mess it up is if you call the render more than once in your loop (that is, you render to like a cubemap, or rendersurface, then having to render the scene).
|
|
|
|
|
Logged
|
JAbstract.....Don't just imagine, make it happen!
|
|
|
|