Earlier quoted context omitted.
> the game is unplayably choppy anyway so it doesn't even matter. My point originally was about this statement of yours, that is purely conceptual and you skew the discussion to address the other part of your comment (or you through that was the point but didn't explain so in your answers) But anyway, one assumption is that every game should have a fixed gamestep, in many single player games (real single player games…
> in most online FPS if the server suddenly slows down all the players start experiencing lag and everyone looks like they are "teleporting" Why would server lag effect FPS? I can only see how it would effect the reported positions of the other players because you aren't getting updates to changes in their movement. Server lag should never effect your FPS.
Doing Game Gravity Right
71–80 of 86 posts
Re: Doing Game Gravity Right
#72Earlier quoted context omitted.
X is time, Y is height. So something like, X time after hitting the jump button, the guy is Y above the ground. (Or you can pretend that the guy is moving towards the right at constant speed, and jumping, and the points in the graphs are the different positions he'll be at :) (Edit: I'm not very sure about the pictures to the left though. Maybe higher jumps/longer time or somethingsomething.)
Yeah, I don't get the difference between the left and right sides of the two graphs either.
Re: Doing Game Gravity Right
#73Earlier quoted context omitted.
> in most online FPS if the server suddenly slows down all the players start experiencing lag and everyone looks like they are "teleporting" Why would server lag effect FPS? I can only see how it would effect the reported positions of the other players because you aren't getting updates to changes in their movement. Server lag should never effect your FPS.
FPS means F irst P erson S hooter here, I reckon.
Re: Doing Game Gravity Right
#74For example some games have entirely reproducible game states which depends on only two things: the seed given to the PRNG and the inputs made the player (and the time at which they happened).
There are a lot of games (probably most of them) which have gravity but which aren't "real" physics simulation and/or which do definitely not need a "real" physics simulation to be, well, fun games.
Some of them do simply use integer-math and precomputed "gravity lookup tables" entirely consisting of integers. You then use the time elapsed to know where you should look in your table and you can of course compute a value "between two lookup indices".
The advantage of integer math (either using gravity lookup table or not), compared to floating-point math, is that your game engine can stay deterministic even if the floating-point numbers implementation vary from one platform / virtual machine to the other.
Re: Doing Game Gravity Right
#75It happens to be an exact solution for one very specific situation -- the case of a constant force that is always applied. In this case, unvarying gravity with no air resistance.
This is typically one of the first things you learn in a Classical Mechanics course, because they can teach it using just Kinematics (the definitions of displacement, velocity, and acceleration) before introducing Dynamics (forces).
To prove it, you can just integrate the definition of acceleration twice and recognize that the integration constants are your initial position and velocity.
If the time-step changes or if forces are due to input, or other changing factors then this is still a pretty terrible method.
Ah ... I should clarify ... the method is not so terrible, but rather the author's explanation and rationale are. Basically, it slightly improves on one little piece of the puzzle, and completely ignores the real issues like fixed time steps, render/physics/network/game logic loop decoupling, and stiff systems.
FWIW, I shipped two hit games this year that only used Euler integration and worse hacks. It made life painful, though.
Re: Doing Game Gravity Right
#76Earlier quoted context omitted.
You'll have small variations at higher framerates too. Why not just avoid variation in this altogether? It's almost no extra work, and it makes things more consistent.
You're also using floats to store the values. This seems silly and looks like it will be slightly slower to calculate. Unless your game is running like garbage this will not matter. You are talking about a dt of something like 1/30 or 1/60
Also, it's very important to people's perceptions of performance (whoa) to maintain a consistent frame-rate. The variations are much more noticeable than the absolute rate. Finally, on lots of hardware, you can't actually display at 59Hz, say. You'll either be at 60 or 30, and will oscillate between the two in a most annoying way.
Re: Doing Game Gravity Right
#77Re: Doing Game Gravity Right
#78Earlier quoted context omitted.
You're also using floats to store the values. This seems silly and looks like it will be slightly slower to calculate. Unless your game is running like garbage this will not matter. You are talking about a dt of something like 1/30 or 1/60
Floats are actually much faster than integers.
You are already storing all these values in floats which is inherently inaccurate. Also if the dt becomes very large you have bigger problems than gravity anyway.
Re: Doing Game Gravity Right
#79Earlier quoted context omitted.
Is this worth making the whole game run slower all the time for everyone? That is what you are talking about here.
This is incorrect. The suggested approach makes the game significantly more accurate adding 3 multiplications and an addition. This does not make the game noticeably slower. If you're concerned about 3 multiplications and an addition you're going to need to show me some profiler data that shows this as a specific bottle-neck in the game-logic.
It doesn't stop at gravity either. Virtually everything in the game world is moving via acceleration. If you were going to do this in a consistent manner you would need to do this for every single physics calculation for every single game world object.
You are correct that you would have to profile it to determine how much of an issue it would be but it sounds like potentially a lot of deadweight to add to the game. Especially since when games slow down it is often due to having a lot of objects in the gameworld simultaneously.
Re: Doing Game Gravity Right
#80Earlier quoted context omitted.
No I am just being realistic as an actual game developer. This is not a conceptual discussion. It doesn't make any sense to implement this change because if your fixed timestep for the physics system is breaking down then gravity not calculating correctly is the least of your problems. The controls would be unresponsive if the dt became large anyway. You are talking about more than doubling the number of operations f…
> the game is unplayably choppy anyway so it doesn't even matter. My point originally was about this statement of yours, that is purely conceptual and you skew the discussion to address the other part of your comment (or you through that was the point but didn't explain so in your answers) But anyway, one assumption is that every game should have a fixed gamestep, in many single player games (real single player games…
I can't think of a framework that doesn't have a fixed timestep except for maybe gamemaker or some of the simpler frameworks. Maybe some of the html5 stuff is non-fixed timestep but that is a field that is just coming into its own right now.
None of the bigger 2d or 3d physics engines today that I know of use a non-fixed timestep.
In platformers with high speed movements fixed timesteps are even more important because of tunneling. You can often account for tunneling in some of the better physics engines but it is sloooow.
In fps games there is a lot of interpolation going on with the server correcting player and object positions. If the server lags you and everything else is going to teleport no matter what. The server is not even accepting your control input at that point so either you are going to desync or you are going to teleport when the server tells you your real position. Generally in fps games only critical physics objects are being server corrected anyway, this is usually a small fraction of the physics objects. For example if an enemy fires a rocket at you that is not usually server corrected. If you get hit in the server calculations then you got hit whether or not you think you dodged it client side.
My point is that if the server hiccups your jump being slightly off is not the big problem, The big problem is that the controls are unresponsive. Also when the server hiccups it is rarely the actual fixed timestep serverside that is your problem, it is the internet. If your computer hiccups then it is not updating positions from the server so all critical objects are going to teleport. Could there maybe be slightly less teleporting on non-player controlled critical physics objects? Maybe so but if you are losing that many timesteps than things are going to jump around on your screen no matter what because your framerate is like 5.