43

I've worked on the networking code for two real time AAA networked games, one for smartphones and one for a handheld console. To directly answer your question "why", well, some games use one or the other because it suits them better than the other. This depends not only on the type of game, but also on what type of network we're talking about (linked arcade ...


34

Okay, I think you have two problems going on here. The first problem is with mipmapping. In general, you don't want to naively mix atlasing with mipmapping, because unless all your subtextures are exactly 1x1 pixel sized, you will experience texture bleeding. Adding padding will simply move the problem to a lower mip level. As a rule of thumb, for 2D, ...


29

You interpolate when you know the 'before' and 'after' values. For example: in a point-and-click game, player is currently at position X, and from his interface, he clicks on spot Y. You must interpolate the displacement between X and Y because you know the two values. You extrapolate when you guess what's going to be future value, based on what you ...


19

One option that'll be a lot easier than fiddling with mipmaps and adding texture coordinate fuzz factors is to use a texture array. Texture arrays are similar to 3d textures, but with no mipmapping in the 3rd dimension, so they're ideal for texture atlases where the "subtextures" are all the same size. http://www.opengl.org/wiki/Array_Texture


18

See also this answer. There are two common ways to use Lerp: 1. Linear blending between a start and an end progress = Mathf.Clamp01(progress + speedPerTick); current = Mathf.Lerp(start, end, progress); This is the version you're probably most familiar with. 2. Exponential ease toward a target current = Mathf.Lerp(current, target, sharpnessPerTick); ...


15

I'll assume your t goes from 0 to 1. (If not, just multiply to scale it appropriately.) Figure out what proportion (0–1) each side is of the perimeter. (side length / total perimeter) To find how much of every side is “filled in” at time t, iterate through sides, subtracting their proportions until t is depleted to a negative value. That last edge (which ...


14

You can use random seed. Select same 32-bit value in server and client (or server can send it to client at start). Use it as seed for random generator. You can send actual seed from server to client with game state update. If you don't want to send it you must be sure that client and server generates same number of random numbers by this random generator. ...


14

Interpolation is done when you have both a start and end value, and you want to estimate what happens between this start and end value. An example would be to move a player from Position A to Position B in a fluid motion. Extrapolation, is done when you have a start value, but do not yet have data for the end. You can then extrapolate based on what data ...


10

Taking this picture: AB is the red vector from A to B. Say P is 25% of the way from A to B. The basic way to get to P from the origin is A + ( B - A ) / 4 = 3/4 A + B / 4 So 3/4 A and 1/4 B. Another way to find that is saying you want a vector 75% "close" to A, and 25% "close" to B. (A vector that is 100% "close" to A is just the A vector.) So you ...


9

For this reason, you'll find simulations are often run 1 or more frames ahead of what is in fact being rendered at given point in time on a give client. So in other words, what you render might in fact be the second last frame, not the last frame. Search this article for all instances of the word "ahead" and I think you will start to get the picture better ...


9

You are looking for a grid traversal algorithm. This paper gives a good implementation; Here's the basic implementation in 2D found on the paper: loop { if(tMaxX < tMaxY) { tMaxX= tMaxX + tDeltaX; X= X + stepX; } else { tMaxY= tMaxY + tDeltaY; Y= Y + stepY; } NextVoxel(X,Y); } There's also a 3D ray-...


9

Yes it's possible, but it's not without its complications. While frame interpolation can work real-time on videos, that isn't necessarily the case with video games. Even though this is processing real-time on videos, the software is able to "look ahead" to the next frame. This is a pretty critical component of interpolation. This is where the issue comes ...


7

From what I see, the game loops you are trying to use are somewhat specialized. I don't know why you chose those ones, but in my opinion you are trying to solve problems that don't exist in the first place. Instead of copy-pasting a game loop from some site, I suggest you think about how your game is made and what your priorities are, and then create a game ...


6

After struggling a lot with this issue, I finally came up with a solution. To use both, a texture atlas and mipmapping, I need to perform the downsampling myself, because OpenGL would otherwise interpolate over the boundaries of tiles in the atlas. Moreover I needed to set the right texture parameters, because interpolating between mipmaps would also cause ...


6

Two that you're missing which immediately stand out to me are GJK and MPR. GJK is an algorithm for finding the closest point of two convex polygons. With a little bit of extra work you can use it to find incident points for intersecting objects, and hence calculate a collision manifold. This is done via polygon clipping, same as if using SAT, but GJK ...


6

Let's assume you want a circular arc from point A to point B, guided by control handle H which is the intersection of the tangents at A & B (and thus equidistant from A & B). Circles being the bread & butter of geometry, there are a hundred ways to skin this cat - but here's one... If we define: midpoint = (A + B)/2; perpendicular = (-(B - ...


6

A system along these lines has been used in The Force Unleashed. I'm not aware of other titles that have used it though.


6

After playing with this function more. I realise that the bezier control points are acting similar to magnets. If I spread the control points so that they are positioned along a straight line with equal distance between, then the animation works as expected { p0: new Vector(0,0), //Start point p1: new Vector(.333,.333), //Control point 1 p2: ...


5

Quick answer: Z is not a linear function of (X', Y'), but 1/Z is. Since you interpolate linearly, you get correct results for 1/Z, but not for Z. You don't notice because as long as the comparison between Z1 and Z2 is correct, the zbuffer will do the right thing, even if both values are wrong. You will definitely notice when you add texture mapping (and to ...


5

While the server has the final say on the position, it should do that by verifying and sanity-checking what the client sends over as the inputs and position. I say this because what you're doing is moving the player immediately and the expectation that creates in your code is that the client is the real position. You think it generally works well, but it's ...


5

Blue's idea is good, but the implementation is a bit clumsy. In fact, you can easily do it without sqrt. Let's assume for the moment that you exclude degenerate cases (BeginX==EndX || BeginY==EndY) and focus only on line directions in the first quadrant, so BeginX < EndX && BeginY < EndY. You'll have to implement a version for at least one ...


5

There are two things crucial to get motion appearing smooth, the first is obviously that what you render needs to match the expected state at the time at which the frame is presented to the user, the second is that you need to present frames to the user at a relatively fixed interval. Presenting a frame at T+10ms, then another at T+30ms, then another at T+...


5

I usually solve this using Catmull-Rom splines. Instead of using control points, you simply specify the two points between which you'd like to interpolate, as well as a "previous" point and a "next" point. If the 4 points all lie on the same line and are evenly spaced, the interpolation will be linear. In the image above, there are four points p0, p1, p2 ...


5

I solved the problem on my own. My previous implementation of the networking engine made reconciliation impossible. The code I am using is private, though I plan on open sourcing the Box2D server/client-side prediction eventually. My solution is as follows: My game code is put into a separate custom Entity-Component-System, called NetEngine. The NetEngine ...


4

I've written an article detailing a slightly different approach, which produces very smooth results: http://www.gabrielgambetta.com/fpm3.html


4

I took a quick look at your example and your code. You're extremely close to solving this, so I don't mind helping with a question that looks suspiciously like homework ;). In data.js, you are assigning the same UV coordinates to the front and rear faces of the cube. The coordinates seem to be ([0,0], [0,0.5], [0.5,0.5], [0.5,0]). This means that you can ...


4

Looks like the issue could be caused by MSAA. See this answer and the linked article: "when you turn on MSAA, it then becomes possible for the shader to get executed for samples that are inside the pixel area, but outside of the triangle area" The solution is to use centroid sampling. If you are calculating the wrapping of the texture coordinates in ...


4

A more generic approach is detailed on Wikipedia. Essentially, that article explains there's no non-iterative method to find the generalized combination of N quaternions with weigths w_i. Nevertheless, if you can supply an approximation of that quaternion "mean", you can iteratively refine it using these update equations: So you could start with m_0 as ...


4

As you are using hlsl I presume you use DirectX. You can use the input semantic VPOS (DX9) or SV_Position (DX>=10): MSDN - VPOS & SV_POSITION semantics When you pass the render target resolution reciprocal one mad is sufficient to construct the screen space uv for every type of geometry. You can not simply do what you proposed as the interpolation does ...


4

It seems the problem caused by Unity's double typed timestamp which is included in the NetworkInfo packet. Since most of the Unity classes utilize from float instead of double, I was applying typecasting on the timestamp which was leading to loss of data. After realizing that, I've inserted my own timestamp using Time.time (a float value) to each packet. ...


Only top voted, non community-wiki answers of a minimum length are eligible