Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (799)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (865)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Adding delta value in character movements?  (Read 7537 times)
0 Members and 1 Guest are viewing this topic.
Offline P0jahn

Senior Devvie


Medals: 1
Projects: 3



« Posted 2016-05-21 21:53:06 »

I see a lot of tutorial use the delta value when moving entities in their game. Personally, I feel like it's a gimmick, so I am not using it in my game, and have not notices any negative impact on different types of PCs.

So my question is, what is the soul purpose of using delta values when moving entities?
Offline chrislo27
« Reply #1 - Posted 2016-05-21 22:03:51 »

The delta time is the time in seconds between frames. It ensures identical movement and speed regardless of how fast a computer can keep up. For example, if you'd want to move 5 units per second, you'd move 5 * deltaTime.

If X computer can run at 60 fps, then in the span of one second, it will execute 5 * 0.01667 60 times. If Y computer can run at only 10 fps, then it will execute 5 * 0.1 10 times. Both add up to 5 in the same time.
Offline jonjava
« Reply #2 - Posted 2016-05-21 22:26:11 »

You're right, it is a gimmick. Don't use it.

Only use it when it has no side effects. Where it doesn't change or affect anything. A pure function if you will. For example interpolation inside the render loop. Although for most games that won't be necessary.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jonjava
« Reply #3 - Posted 2016-05-21 22:33:26 »

It ensures identical movement and speed regardless of how fast a computer can keep up.

In theory yes, in practice no. What you should do instead to get consistency is to call the tick an extra time for each dropped frame.

Offline P0jahn

Senior Devvie


Medals: 1
Projects: 3



« Reply #4 - Posted 2016-05-22 12:54:15 »

So basically it's like if the computer is unable to run the game at 60fps, we "jump" the characters to trick the human eye into smoothness. Wouldn't that mess up collision detection?
Offline VaTTeRGeR
« Reply #5 - Posted 2016-05-22 13:26:41 »

yes it would mess up collision if kept unbounded, physics simulations often use fixed time steps to not allow any glitches of that kind.

if your delta values get too small or to big, numeric stability goes out of the window and everything breaks,
so you need to bound it.
If you add a very very small float value to a very big float value only the big value remains as the result because of limited precision and rounding.

in a game this results in a unit not moving at all if it is very slow.
Offline theagentd
« Reply #6 - Posted 2016-05-22 15:21:15 »

<a href="http://www.youtube.com/v/o9dZm5h2oNQ?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/o9dZm5h2oNQ?version=3&amp;hl=en_US&amp;start=</a>

Don't be Call of Duty.

Myomyomyo.
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (203 views)
2019-09-04 15:33:17

hadezbladez (4941 views)
2018-11-16 13:46:03

hadezbladez (1820 views)
2018-11-16 13:41:33

hadezbladez (5217 views)
2018-11-16 13:35:35

hadezbladez (1028 views)
2018-11-16 13:32:03

EgonOlsen (4402 views)
2018-06-10 19:43:48

EgonOlsen (5235 views)
2018-06-10 19:43:44

EgonOlsen (2976 views)
2018-06-10 19:43:20

DesertCoockie (3878 views)
2018-05-13 18:23:11

nelsongames (4311 views)
2018-04-24 18:15:36
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!