Fixing the most common glitches in AAA games
The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.
No matter how long it takes a new game to born, even after a year of patches after the final version of an AAA game (like FarCry 4), we are used to see the same bugs over and over again, are those glitches so hard to fix?
I have arranged a list of bugs along these categories: rendering and complex technology plugins, programming AI and physics, networking.
- Shadow striping
A low shadow depth bias can cause this, but if you need to lower this value because a frame drop, then you may want to change light params and add conditions in affected objects.
this error can also be a result of the configuration of the shadows for the current hardware, that changes between DX9-11, PS3, XBOX360, etc. and it can bring the developers to a higher level of consequences (invisible car shader bug).
- Wrong shadow projection
a box shadow appeared in the ground, probably because of the depth buffer bug or bad frustrum, or it is an invisible object (like a house) that is not being removed from the projection.
here ,an invisible tree is casting its shadow, we should check that removed these objects once activated/deactivated, to be added/removed to the light shadow projection. Sometimes it is better to bake the shadows inside the level textures.
Level of Detail
Choose the right distance and proper models to change
This is what happens when you do the change too fast or abrupt with obviously low detail models:
This technique is used when the far limit of our camera is too high (1000 or more by default in Unity!) and we are also using a big FOV too (defaults: 60 in Unity, 19 in ShiVa, 90 in Unreal!). This may result in a lot of objects to be rendered each frame, to reduce the draw calls the distant objects models are being replaced with lower detail alternatives: LOD ,instead of hidden them, that gives a better sensation of immersion and depth to the game. To fix this we could build a set of static batching objects, arrange them in sectors, and activate the whole sector when the camera is far ,and use only 2 LOD to improve the quality. Some games, only have one LOD model with low quality
in this pic you can detect the low detailed model very easily.
Complex technology plugins
developers love new technology, we try to adopt the new stuff asap, but sometimes it drive the game to unexpected results
- Hair technology
I'm supposing that the complex hairs are being rendering in the wrong buffer order, so the background behind the house is in the top and that is what you see. You may want to adjust this order in complex cases like this one to avoid this result.
The realistic hair used in games are better and with more high quality each new version, compared to previous techniques,the new ones are significally better, like this one in Far Cry 4 from nvidia tech
- Terrain technology
each engine has it own terrain plugin, ...and bugs, in Unity it does not allow you to rotate the geometry without changing the height map, for example.
But there are other things we should consider too
But if you want to fix this in the terrain engine, well that will take more effort.
- Animation technology
These are amazing plugins that, mixed with motion capture can create the perfect animation for games like a blockbuster movie, or make the sea physics perfect.
The fixing of these animation glitches is related to the animation parameters that the plugin uses, sometimes because of physics, others because of the game loop and timing,or this:
because of the model skin import (of the animation), fix: reimport the models, animations and assigning properly.
AI and physics glitches
Programming Finite State machines
- Transitions between states: NPCs
We can find these bugs in a lot of AAA videogames.
A transition system should handle the changes between NPC states successfully.
I'm assuming that games like FC3 and FC4 are using this finite state machine, engines like Unity has their own states machine tools to design them.
This is a basic scheme for a state change (transition)
but when you don't do a great job checking conditions, you end up entering a wrong state in the machine, and this is the result
Here, the NPC is moving usnig physics, but the animation was locked, maybe because it goes throught the DEAD state and come back to LIVING state without changing the animation. The ragdoll physics are running too.
To fix this you have to be sure of the locking process is doing right:
if a NPC is alive and she gets a bullet, then she dies, the LIVING state should be locked, changed to DEAD, and by locking this state, it is impossible that she return to the LIVING state.
The same goes for the glitches when a char changes from a DRIVING state inside a vehicle to WALKING, you have to assert the conditions of walking before start moving in the new state:
- Transitions between states in game logic: missions and skills
Here you can see a transition bug in a mission:
the explossions are looping, the mission state is not chaning, can be caused by a missing condition in the trigger events for example, or a bug when the mission is restarted and not properly reset the counters,etc.
Programming bugs are fixed debugging the code and trying to watch the vars for counters, states, and transitions. [video: mission trigger start bug being a pigeon in GTAV]
Problems using Rays and Physics
Set the correct position for a game object using a complex level geometry
When you use rays to translate objects you are taking some risks
the red lines are the rays fired from the player position, -used in this case to move bullets-, you have to check the layers of the objects and then add the logic to made changes in the game, if the origin is inside other geometry and you need to re-locate the player, well, that is a problem.
With complex terrain geometry and colliders with various levels of height, caves, etc., then ,you need some alternatives to find a safe spot where the player can be dropped. Things like these can happen:
In this GIF, you can see the problem, the ray is fired from too high,or mabye from the player position with an up direction vector, and in the first iteration of the algorithm it first hit the little LCPD stall model geometry,but there is no room to drop the player object there, it goes up, another ray hit the bridge, no room, then go up, over the roof!, in the other example , the npc is already behind the terrain and it tries to go up, but the model collider is inside the terrain so it interprete this as another step so it changes the animation and go up up.
It can get more complicated, for example,with a quadruped NPC:
Could you avoid this by adding a ray casting looking down?
the more rays you use, the more conditions and checks you will have to add and make the char move properly in the world. So, is it a good idea to add a ray to check the ground?,well. if the game object already uses a collider with a dynamics component, you can know if it is grounded ,not only because of the collisions information but also using the speed in the Y axis -rigid body- at a given time, and a quick check with this data is cheaper than casting a new ray.
It is important that the origin of the ray is being set in the position of the player, and inside its collider (ignoring its layer for collision), this collider should be filling all the player model mesh, to avoid weird cases like ,when the mesh enters other geometry or casting rays inside the wrong places
In this gif: a npc inside a rock. This bug is in a lot of games, one of the problematic consequences of a bad destiny as a result of the path finding using rays is to place the object inside other object, for example, set the position of the player object/npc inside a rock, locking it inside like a jail.
To solve this we can use a set of safe nodes where only certain kind of objects can spawn, or use a spiral square search to find a spot:
or you can instantiate a dynamics sphere in the destinty point and then make it grown exponentially so the spot is free to release the player there. [bear attacking inside the house from the outside as bonus video].
To summarize: rays are used in a lot of cases, games like AC series and many others use them mixed with IK solvers (Human IK) to position the feet of the char over the geometry while it is animating, or in The Order 1886 to make the char feels like he is really touching things with his fingers, and they keep improving it.
The use of ragdolls add a real physics feeling but only a few games do a good job replacing the model skin with a ragdoll, in my opinion, the ragdolls physics in Diablo 3 made by Erin Catto,the creator of Box2D (my tutorial for this p. engine) is one of the bests, then ,there are other cases...watch this de-sync between the physics and the world in Dungeon Hunter 5 by Gameloft
the not balanced ragdoll bug can be solved in 10 minutes if the effort is put in the task. And you can see problems with them in a lot of AAA titles, for example Thief,or
... Dishonored. You have to balance the weights,and it is the task of the 3d modeler and the programmer.
User Interface and saved data
This happened to me:
It says it can't unlock all the skills left because I have to unlock the previous ones, ...that are already unlocked. I guess this is a glitch with saved data, that may happen when the unlocked skills save event was interrupt by other and now it counts as unlocked only in the hud but not in the data. You should check that sums are right and fix components if not.
Hearthstone bug in GUI deck name:
The xml to define font style is not being filtered correctly because it uses a card deck's name with the same name of a game boss that is not being translated (return the same string).
You can replicate this bug naming your deck with a boss name (from the adventure game mode). This bug can be solved in code, the class used is an UberText, the C# version. The ProcessText function does something like this:
this line adds a Bold style to the font used in the HUD label, but then, the material used for the font is not found because of a translation error and it does not make the replacement (remove the xml from string).
There are more errors with HUD (or GUI), but AAA games normally does a great job here, so, next!.
Glitches in networking
The most difficult bugs to fix,take a look to this bug collection most of them, online
With lag, comes the chaos, some of the bugs are the same as the ones we have just view, because combining networking and physics is hard to keep integrated in a game.
Sync client/server time for all the players
Load balancing is not enough to prevent glitches in multiplayer games, you also need a way to measure and combat lag by setting a mechanism to make sure what player did what action before another (also based on best probability functions).
in this gif some players are being pushed by the force of the explosion before the animation and others some miliseconds after.
Even with client/server time, problems can emerge in complicated cases, like the ones related to states and events, if player A from blue team is casting the spell to teleport home and player B from red team shoots player A just before the spell is completed but the missile speed is not enough to reach the target and still hit it and dies,...that's a bug, we need to check times, make a calculation based on the actions and accept or deny the shot depending on the conditions, the distance should be important once the missile arrives the target.
There are plenty of errors in the network layer to be solved.
And that's it ,for now, if you know more bugs fixes please leave a comment.
Source: Original post.
I end up thinking that is more profitable to ship games with funny bugs, as a new dimension of diversion