------ squared game design vision control

------ squared game design vision control

Reference URL: https: //blog.csdn.net/qq_36748278/article/details/102787225

background

Players perspective background

AOI (Area of ​​Interest), i.e., the region of interest. It can be regarded as area players in the game in real time where the scene to see, that with the movement of the player's AOI will change. In the game, there will be many scenes (map), each map has a lot of player or npc, view data is mutual, we can see that Player B Player A, Player B will also see that the player A. When players do some behavior when operating in the map, if you want the player's behavior to be seen, it is necessary to broadcast the player's behavior to all players in the map. The scene in which players act as long as the modifications to the scene broadcast to all other players in this way is the best way?

  • For some of the smaller number of players scenes, such as a copy of the team and so on. Players will see all the players and npc map, it can be called full-field scene. In this scenario, there is a single player action to take other players the way to the scene broadcast is feasible.
  • For some large-scale PVP play, same scene there are hundreds or even thousands of people to participate when, assuming a total of 1000 people attended the scene. Any player as long as the move is necessary to broadcast to the rest of the 999 people, when 1,000 people moving at the same time, the server needs to handle 999 * 999 (million level) messages, equivalent to n * n. Everyone at the scene moved on to produce one million level data, not considering the synchronous operation of other acts such as the release of the player's skill, so the accumulation of large amounts of data easily cause the server message, do not respond in a timely manner. At the same time, the client every player will handle real-time information other 1000 players, likely to cause the client Caton, if the message handle, however lost data packets will also appear. While the sheer number of packets sent to the client, but also consume a large amount of traffic. This is certainly not the way we want, the game experience will be very poor.

We can see that in the game, players will always appear in the center of the screen, along with the player's movement, vision will move simultaneously with the movement of the players, but the players always are at the center. Players can see the game screen is player-centered extension 360 degree view of the surrounding information. So if the player to modify the AOI, the player-controlled at the center of the screen can see all objects referred to as a player's view data; others behavior when the player has operated, the player only needs to inform the field of view, with respect to notification scene all players can reduce a lot of unnecessary push messages, but can also save a lot of traffic. Because other users are too far away is not on the current screen, the player's behavior operating within the scope of the notice to these players is no sense of the players.
But if this scenario all players are playing a boss, the scene all the players together, then the player's current view data screen has become all the players in the scene. At the same time limited by the performance of the client, the client has the largest number of people with ceiling screen, so we need to limit the upper limit of the field of vision of the player. When all the players together in the scene set to filter by priority (social relationships, hostile relations, distance, etc.), screened a specified number of objects counted in the player's field of vision objects.

Therefore, for large-scale PVP play activities, when the number of scenes in a lot of the time, the player's field of vision using vision ceiling limit, and player-specified range of 360-degree field of vision of the player is set to the center of the way. Player-centered, extended to the surrounding 360-degree, the player may extend to the center of the square region, the player may be based on the center of the circular area. However, due to the square when the map, is not suitable for calculating the coordinates of the circular range of the critical point, so that according to the best player-centered square region 360 extended outward. We can find out exactly around is a player-centric square area. Therefore, it is conceivable in accordance with their respective division of the map area, the player at the center of the grid, with the player just as the center square area can be divided into 3 * 3 squares. And greater than or equal squared area requires a game screen display area, depending on the circumstances to rational design length of each map grid. Thus the player's view data storage may take the form of squares.

Here Insert Picture Description

map

Map grid division

In the game, the size of the map are square, and is X-axis, Z-axis in a horizontal plane (in both the game in cm). The grid map into a plurality of specified size, such as in 7M (map according to the actual size of a single length of grid size) in units of the divided blocks. After the map is divided into a plurality of map tiles, which the player can be calculated by the tile coordinate points of the player.
Divided in the X-axis direction, the X-axis map a total length of 256m, assuming that the size of each block is 7m, then the X-axis, total number of tartan? 256/7 = 36.57142857142857, a lattice is not satisfied directly calculated according to a lattice, the X-axis total of 36 + 1 = 37 grid, Z axes empathy. Assuming that the size of each block is 8m, 256/8 = 32, just may be divided into 32 blocks. When the map fixed size, different sized blocks, will not give the number of the lattice, and some may be divisible, some not divisible (not divisible counted does not satisfy a size 1), i.e., rounding up. To avoid divisible condition judging whether, uniform application plus 1, i.e., using the map length / length + 1 to the number of lattice grid is calculated for each division. So we divided the total number of grid will always be larger than the scene of the map. Assuming that the size of the map is 256m * 256m, the size of each grid is 7m * 7m, is discussed below are in accordance with the size.

  • Total number of grid X_AREA_NUM_PER_MAP X-axis lattice length of each of the X-axis = Map Length / X-axis + 1
  • Total number of grid = Z_AREA_NUM_PER_MAP Z-axis Z-axis length of each grid Map Length / Z-axis + 1
  • There are entire map grid number MAX_DYN_AREA_NUM = X_AREA_NUM_PER_MAP * Z_AREA_NUM_PER_MAP + 1 (here add a lattice for security reasons)

Game one-dimensional array to store all the map grid can be used. Lattice Number --1 = array subscript, then get stored in the array corresponding to the shared memory by the index ID, which can obtain a corresponding block of the target field of view (a field of view lattice can be regarded as a target block).

Block map field of view (grid) array and the subject related as follows:
Here Insert Picture Description

Location coordinates of the point positioning block players

How to find which players are in the grid according to the specific coordinates of the point of it?
Column X-axis direction: a first range of lattice [0,7), the second lattice range [7,14), the third grid range [14,21) ...
the Z-axis row direction: a first range of lattice [0,7), the second lattice range [7,14), the third grid in the range [14, 21) ...

Players known coordinates pos (8, 100, 15) , the map size is assumed 256m * 256m, the grid size is 7m * 7m.
A two-dimensional array can first subscript Analysis:
X-axis, where X is the number of lattice X = 8/7 = 1, i.e., in the X-axis lattice column 2 (Figure), the X-axis array subscript 1
in Z-axis, the number of lattice where Z is Z = 15/7 = 2, i.e., the lattice layer 3 in the Z axis (FIG.), Z-axis array subscript of 2
, where an array of players according to a two-dimensional array subscripts calculated the subscripts: Z * X_AREA_NUM_PER_MAP + X = 2 * 37 + 1 = 75
Here Insert Picture Description

Relationship map, vision blocks, players

Here Insert Picture Description
The game will have a lot of scenes;
each scene corresponds to a map resource;
will be divided into a plurality of cells on each map, each grid block object is a vision;
there will be many players on each field or npc block.

The player's view

The player's view are subject to change following two cases

  • Active: Vision player operation caused refresh:
    Players enter the map, the player's field of vision will search information.
    The player moves, moving from one field to another block of the block field of view (if the same is moved in a grid, the field of view is not refreshed).
  • Passive: Other causes of changes in the player's field of vision:
    other players to enter / leave the field of vision, it can cause changes in their vision.

Players move may lead to the situation of the field of view refresh

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

Code

Related to the specific player's view update logic, refer to refer to the URL given above

github address

Published 155 original articles · won praise 15 · views 160 000 +

Guess you like

Origin blog.csdn.net/wangdamingll/article/details/105207975