|
| 1 | +--- |
| 2 | +title: "Game and Bug: Portal" |
| 3 | +--- |
| 4 | + |
| 5 | +[:material-arrow-left-bold: Back to post list](../index.md){ .md-button } |
| 6 | + |
| 7 | +`2025. 02. 10.` |
| 8 | + |
| 9 | +While working at a game company in 2019, I worked on fixing bugs reported by users. Among various bugs, I still remember investigating an incident where when two users simultaneously used portals to move to different areas, suddenly the other character disappeared and only their health bar was floating in the air. How did this happen? To understand this, we need to understand game operation principles and various implementation techniques. |
| 10 | + |
| 11 | +First, we need to know what a portal is. Simply put, a portal is a gateway-type device that allows instant travel between two distant spaces. Depending on how we define this 'instant' time, we can think of similar devices in the real world - for example, an elevator could be considered a kind of portal in that after waiting a few seconds after boarding, you can move directly from a low place to a high place, or vice versa. However, there is one huge difference between game portals and real elevators: 'where does the subject of movement exist while moving through this device?' |
| 12 | + |
| 13 | +Unless we take a science fiction approach of copying the atoms that make up the body and transferring them to another space, in the real world, my body must always exist along the path of movement connecting two points when moving from one point to another. So what about in games? In the game I was maintaining, there was no concept of continuity of body in space. If we consider that everything that happens in the game consists of a series of still frames, my character who was at position A in one frame will be at position B in the very next frame after using a portal. Not only did the character not exist in any space between A and B, but it's very important to note that all character actions are explained in terms of frames. |
| 14 | + |
| 15 | +And these frames are calculated on the computer where I'm playing the game. Specifically, the work of combining various terrain, obstacles, monsters, and player information to create visual images happens on my computer. Terrain and obstacle information is pulled from information stored on my computer, while monster and other player information is received from servers managed by the game company. Of course, my character needs to appear on other players' screens too. For this, while I'm playing, my computer continuously sends information about my character's position, skills being used, items, etc. to the game company's server, and other players' computers use this information to create their screens. |
| 16 | + |
| 17 | +One thing to be mindful of when creating frames is that it should take as little time as possible. If about 60 frames are produced per second, the game I'm playing will feel smooth, but if only about 10 frames per second can be calculated, the screen will appear to stutter. As mentioned earlier, calculating one frame requires information about various terrain and players and other objects in the game. This information includes things like monster types and health, as well as 3D modeling information for monsters and players. Among these, 3D modeling information is calculated into visually visible information through the render engine, and since this takes a lot of time, it's important to exclude unnecessary 3D information from frame calculations as much as possible. |
| 18 | + |
| 19 | +So in the game I was maintaining, we used a technique to only use information about elements around my character in frame calculations. With each frame calculation, we check if there are any changes to elements around my character, update them, and only consider these elements in frame calculations. A tree very far from my character doesn't need to be shown on screen and doesn't affect elements visible on my screen, so my computer calculates frames without knowing the tree's information. Later, when my character goes near the tree, only then does it receive the tree's information and prepare to use it in frame calculations. Similarly, if my character moves away from a monster that was originally nearby, my computer deletes the monster's information. From my computer's perspective, since it doesn't need to consider the monster's information in frame calculations, it eliminates the monster's existence entirely. |
| 20 | + |
| 21 | +Now let's return to the bug where when two players used portals simultaneously, the other player's character who came through the portal together disappeared and only their health bar remained. This bug occurred in the following way: First, my character used a portal to move to a distant location. Then my computer determined that the other player wasn't near me and deleted their 3D information. In the very next frame, it should have deleted the character's unique information too, but right at that moment, the other player came near me through the portal. As a result, the other character was determined to be near me, so the game engine doesn't delete the unique information. In other words, from the game engine's perspective, it judges that the other character has been near me all along, so it doesn't update the 3D information and leaves it in its deleted state. Since the character's health bar is displayed using the character's unique information, to me it appears as if only the other player's health bar is floating with their character invisible. |
| 22 | + |
| 23 | +In reality, we don't eliminate others around us when they disappear from our sight, and we usually don't need to worry about dramatic events occurring within millisecond time intervals. If we try to connect virtual experiences with real experiences, we might need to pay attention to the points where real rules and virtual rules meet. |
| 24 | + |
| 25 | +[:material-arrow-left-bold: Back to post list](../index.md){ .md-button } |
0 commit comments