Method, device and electronic device for controlling character movement in football games
By determining the target movement position according to the current football position and NPC identity attributes in football games, the NPC mobile control method is too simple in the existing technologies, realizing more flexible and random mobile performances, which improves the real sense of the game.
Patent Information
- Application Number
- CN202111509714.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-10
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2041-12-10
AI Technical Summary
In existing football games, the movement control method of non-player controlling characters NPCs is too simple, resulting in a fixed distance between players, a rigid movement performance, lacking randomness and flexibility, and being unable to simulate football games.
By obtaining the current football position and the identity attributes of NPCs, the target movement position of the NPC is determined, including the target movement point, trajectory or area, and control the movement of NPC based on this position to improve the flexibility and randomness of movement.
Realize the flexibility and randomness of NPC movement in football games, enhance the authenticity of the game, and make the game experience more pleasant.
Smart Images

Figure CN114225397B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of game design technology, and in particular to a method, device and electronic equipment for controlling the movement of a character in a football game. Background Art
[0002] In the process of football game design, the performance of the game is important and fundamental. In the 3D game performance screen, the movement of characters (players, referees) is the key to the performance of the game, that is, the AI behavior design of the football game. Its purpose is to set basic football rules as the basis of the game battle and simulate the real and comprehensive football game process. Design an intelligent system that can show smooth games, thereby providing game players with a pleasant experience.
[0003] Currently, the football games on the market are mainly card games. The movement control of non-player characters NPC in the game is usually very simple, such as controlling the players on the field to move without the ball or with the ball at a simple fixed distance. Some games are even simplified to the point where there is no referee or movement rules. This simple fixed-distance movement method causes players to always maintain a certain distance, making the entire movement performance appear rigid, lacking randomness and flexibility, and unable to simulate the game and show a real football game. Summary of the invention
[0004] The purpose of the present application is to provide a method, device and electronic device for controlling the movement of a character in a football game, which can determine the target movement position of the character according to the identity attributes of the character and the current position of the football, and control the character to move based on the target movement position, thereby ensuring the flexibility and randomness of its movement and improving the realism of the football game.
[0005] In a first aspect, an embodiment of the present application provides a method for controlling character movement in a football game, the method comprising: obtaining a current football position in a game scene in a current control cycle and the identity attributes of each non-player controlled character NPC; for each NPC, determining a target moving position of the NPC in the current control cycle based on the current football position and the identity attributes of the NPC; the target moving position comprises: a target moving point, a target moving trajectory or a target moving area; and controlling the NPC to move in the game scene in the current control cycle based on the target moving position corresponding to the NPC.
[0006] Furthermore, the above-mentioned step of determining the target moving position of the NPC in the current control cycle based on the current football position and the identity attributes of the NPC includes: if the identity attributes of the NPC are non-referee and non-goalkeeper, obtaining the current state corresponding to the team to which the NPC belongs, and the character position corresponding to the NPC in the previous control cycle; the current state includes an offensive state or a defensive state; determining the target point corresponding to the NPC in the preset stadium dot matrix according to the identity attributes of the NPC; each point in the preset stadium dot matrix corresponds to a player with a specified identity attribute in a team formation; determining the target moving point of the NPC in the current control cycle according to the current state, target point, current football position and character position.
[0007] Furthermore, each column of points in the above-mentioned preset court dot matrix corresponds to a designated line; the preset court dot matrix corresponds to the back line, back waist line, midfield line, front waist line, forward line and center line from left to right; the step of determining the target moving point of the NPC in the current control cycle according to the current state, target point, current football position and character position includes: obtaining the target designated line to which the target point belongs in the preset court dot matrix; calculating the coordinate components according to the ball coordinates corresponding to the current football position and the character coordinates corresponding to the character position; determining the coordinate adjustment parameters corresponding to the character coordinates according to the current state, target designated line, coordinate components and ball coordinates; the coordinate adjustment parameters include: coordinate offset value, coordinate offset coefficient and target coordinate value; based on the coordinate adjustment parameters, adjusting the character coordinates to obtain the target moving point of the NPC in the current control cycle.
[0008] Furthermore, the above-mentioned step of determining the coordinate adjustment parameters corresponding to the character coordinates based on the current state, the target designated line, the coordinate components and the spherical coordinates includes: if the current state is an offensive state and the target designated line is a back line, multiplying the coordinate components by a first preset coefficient to obtain a coordinate offset value corresponding to the character coordinates; if the target designated line is a non-back line and the Z value in the spherical coordinates is less than a first threshold, determining the coordinate offset value corresponding to the character coordinates based on the character coordinates, the coordinate components and the spherical coordinates; if the target designated line is a non-back line and the Z value in the spherical coordinates is greater than or equal to the first threshold, determining the coordinate offset value or coordinate offset coefficient corresponding to the character coordinates based on the target designated line, the coordinate components and the spherical coordinates.
[0009] Furthermore, the above-mentioned step of determining the coordinate offset value corresponding to the character coordinates based on the character coordinates, coordinate components and spherical coordinates includes: subtracting the product of the x-axis coordinate component and the second preset coefficient from the x-coordinate of the character coordinates to obtain the x-axis coordinate offset value corresponding to the character coordinates; and using the z-coordinate of the character coordinates as the z-axis coordinate offset value corresponding to the character coordinates.
[0010] Furthermore, the above-mentioned step of determining the coordinate offset value or coordinate offset coefficient corresponding to the character coordinates based on the target designated line, coordinate components and spherical coordinates includes: multiplying the z coordinate in the spherical coordinates by the designated coefficient corresponding to the target designated line to obtain the z-axis coordinate offset value corresponding to the character coordinates; if the target designated line is the front waist line or the center line, determine the first correction value according to the z coordinate in the spherical coordinates, and multiply the first correction value by the third preset coefficient to obtain the x-axis coordinate offset coefficient corresponding to the character coordinates; if the target designated line is the back waist line, the midfield line or the forward line, multiply the x-axis coordinate component by the fourth preset coefficient to obtain the x-axis coordinate offset value corresponding to the character coordinates.
[0011] Furthermore, the above-mentioned step of determining the coordinate adjustment parameters corresponding to the character coordinates according to the current state, the target designated line, the coordinate components and the ball coordinates includes: if the current state is a defensive state, determining the target correction value according to the ball coordinates and the target designated line; determining the z-axis target coordinate value corresponding to the character coordinates according to the target correction value; if the target designated line is a back line, a back waist line, a midfield line or a front waist line, determining the x-axis coordinate offset coefficient corresponding to the character coordinates according to the identification-related value corresponding to the target designated line; determining the x-axis coordinate offset value corresponding to the character coordinates according to the x-axis coordinate component of the coordinate component; if the target designated line is a forward line or a center line, determining the preset value as the x-axis offset coefficient corresponding to the character coordinates.
[0012] Furthermore, the above-mentioned step of determining the target correction value based on the spherical coordinates and the target designated line includes: determining the initial correction value based on the target designated interval where the z coordinate of the spherical coordinates is located; different designated intervals correspond to different correction calculation formulas; and determining the target correction value based on the initial correction value and the relationship between the threshold value corresponding to the z coordinate and the target designated line.
[0013] Furthermore, the above-mentioned step of adjusting the character coordinates based on the coordinate adjustment parameters includes: if the coordinate adjustment parameters include a coordinate offset value, summing the character coordinates with the coordinate offset value; if the coordinate adjustment parameters include a coordinate offset coefficient, multiplying the character coordinates with the coordinate offset coefficient; if the coordinate adjustment parameters include a coordinate offset coefficient and a coordinate offset value, multiplying the character coordinates with the coordinate offset coefficient, and summing the obtained product with the coordinate offset value; if the coordinate adjustment parameters include a target coordinate value, using the target coordinate value to update the character coordinates.
[0014] Furthermore, the above-mentioned step of determining the target moving position of the NPC in the current control cycle based on the current football position and the identity attribute of the NPC includes: if the identity attribute of the NPC is a goalkeeper, obtaining the corresponding character position of the NPC in the previous control cycle; calculating the first distance between the football and the NPC based on the current football position and the character position; judging whether there is an opposing player in a first designated area based on the character position; if so, determining the corresponding target moving trajectory of the NPC based on the first distance; if not, determining the corresponding target moving area of the NPC based on the first distance.
[0015] Furthermore, the above-mentioned step of determining the target moving trajectory corresponding to the NPC based on the first distance includes: determining the second distance between the NPC and the center of the goal based on the first distance; the second distance is positively correlated with the first distance; determining two intersection points of a circle with the target moving point as the center and the second distance as the radius and the large penalty area; wherein the target moving point is: a point on a vertical line passing through the center of the goal and perpendicular to the side of the goal away from the court, the distance from the center of the goal is half the length of the goal; and determining the arc between the two intersection points as the target moving trajectory corresponding to the NPC.
[0016] Furthermore, the above-mentioned step of determining the second distance between the NPC and the center of the goal based on the first distance includes: searching for a target distance segment corresponding to the first distance from a preset distance correspondence relationship; the preset distance correspondence relationship includes: a correspondence between the distance segment between the football and the goalkeeper, and a correspondence between the distance between the goalkeeper and the center of the goal; and determining the target distance corresponding to the target distance segment as the second distance between the NPC and the center of the goal.
[0017] Furthermore, the above step of determining the target movement area corresponding to the NPC based on the first distance includes: determining a second designated area based on the first distance; and determining the second designated area as the target movement area corresponding to the NPC so that the NPC can attack.
[0018] Furthermore, the above method also includes: obtaining the current speed of the football, and the third distance between the character position and the target moving position; determining the moving speed of the NPC based on the current speed and the third distance; and controlling the movement of the NPC based on the moving speed and the target moving position.
[0019] Furthermore, the above-mentioned step of determining the target moving position of the NPC in the current control cycle based on the current football position and the identity attributes of the NPC includes: if the identity attribute of the NPC is the referee, obtaining the current state of the NPC; judging whether the current state is a designated penalty kick state; the designated penalty kick state includes one of the following: corner kick state, midfield kick-off state and penalty kick state; if yes, determining the preset position as the target moving point corresponding to the NPC; if not, determining the position relationship between the football and the target diagonal line according to the current football position; the target diagonal line is the diagonal line obtained by connecting the two diagonal points of the two large penalty areas; determining the target moving point corresponding to the NPC according to the position relationship and the current football position.
[0020] Furthermore, the above step of determining the target moving point corresponding to the NPC based on the position relationship and the current football position includes: if the position relationship is that the football is on the target diagonal line, determining a circle with the current football position as the center and a preset distance as the radius; and determining a specified point on the circle as the target moving point corresponding to the NPC.
[0021] Furthermore, the above-mentioned step of determining the target moving point corresponding to the NPC based on the position relationship and the current football position includes: if the position relationship is that the perpendicular line between the football and the target diagonal passes through the target diagonal, calculating the vertical distance between the football and the target diagonal; based on the vertical distance, determining the target moving point corresponding to the NPC on the vertical line segment corresponding to the vertical distance.
[0022] Furthermore, the above-mentioned step of determining the target moving point corresponding to the NPC on the vertical line segment corresponding to the vertical distance based on the vertical distance includes: reducing the vertical distance according to a preset ratio to obtain the target distance; determining a target moving point whose diagonal distance from the target is the target distance on the vertical line segment corresponding to the vertical distance; and determining the target moving point corresponding to the NPC based on the target moving point.
[0023] Furthermore, the above step of determining the target moving point corresponding to the NPC based on the target moving point includes: judging whether the target moving point is within the restricted area; if so, taking the intersection of the vertical line segment and the large restricted area as the target moving point corresponding to the NPC; if not, taking the target moving point as the target moving point corresponding to the NPC.
[0024] Furthermore, the above-mentioned step of determining the target moving position corresponding to the NPC based on the position relationship and the current football position includes: if the position relationship is that the perpendicular line between the football and the target diagonal passes through the extension line of the target diagonal, determining the perpendicular line segment of the extension line of the football and the target diagonal; determining the target vertical line segment that passes through the diagonal point of the penalty area and is parallel to the vertical line segment; and determining the target moving point corresponding to the NPC on the target vertical line segment.
[0025] Furthermore, the above-mentioned step of determining the target moving position of the NPC in the current control cycle based on the current football position and the identity attribute of the NPC includes: if the identity attribute of the NPC is a linesman, determining the intersection of the vertical line between the second-to-last player and the linesman in the half where the NPC is located and the linesman; and determining the intersection as the target moving point corresponding to the NPC.
[0026] Furthermore, the above-mentioned step of controlling the movement of the NPC in the game scene in the current control cycle according to the target moving position corresponding to the NPC includes: if the target moving position includes: a target moving point, controlling the NPC to move to the target moving point in the game scene in the current control cycle; if the target moving position includes: a target moving trajectory, controlling the NPC to move according to the target moving trajectory in the game scene in the current control cycle; if the target moving position includes: a target moving area, controlling the NPC to move within the target moving area in the game scene in the current control cycle.
[0027] In the second aspect, the embodiment of the present application also provides a character movement control device in a football game, the device comprising: a data acquisition module, used to obtain the current football position in the game scene in the current control cycle, and the identity attributes of each non-player controlled character NPC; a position determination module, used to determine the target movement position of the NPC in the current control cycle for each NPC according to the current football position and the identity attributes of the NPC; the target movement position includes: a target movement point, a target movement trajectory or a target movement area; a movement control module, used to control the movement of the NPC in the game scene in the current control cycle according to the target movement position corresponding to the NPC.
[0028] In a third aspect, an embodiment of the present application further provides an electronic device, including a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the method described in the first aspect above.
[0029] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the method described in the first aspect above.
[0030] In the method, device and electronic device for controlling the movement of characters in a football game provided by the embodiments of the present application, the current football position in the game scene in the current control cycle and the identity attributes of each non-player controlled character NPC are first obtained; for each NPC, the target movement position of the NPC in the current control cycle is determined according to the current football position and the identity attributes of the NPC; the target movement position includes: a target movement point, a target movement trajectory or a target movement area; according to the target movement position corresponding to the NPC, the NPC is controlled to move in the game scene in the current control cycle. The embodiments of the present application can determine the target movement position of the character according to the identity attributes of the character and the current football position, and control the character to move based on the target movement position, which can ensure the flexibility and randomness of its movement and improve the realism of the football game. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0032] Figure 1 A flowchart of a method for controlling the movement of a character in a football game provided by an embodiment of the present application;
[0033] Figure 2 A schematic diagram of a preset court dot matrix provided in an embodiment of the present application;
[0034] Figure 3 A schematic diagram of a preset distance correspondence relationship provided in an embodiment of the present application;
[0035] Figure 4 A schematic diagram of a target moving position determination process provided in an embodiment of the present application;
[0036] Figure 5 A schematic diagram of another target moving position determination process provided in an embodiment of the present application;
[0037] Figure 6 A schematic diagram of another target moving position determination process provided in an embodiment of the present application;
[0038] Figure 7 A schematic diagram of another target moving position determination process provided in an embodiment of the present application;
[0039] Figure 8 A schematic diagram of another target moving position determination process provided in an embodiment of the present application;
[0040] Fig. 9 A structural block diagram of a device for controlling the movement of a character in a football game provided by an embodiment of the present application;
[0041] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0042] The technical solution of the present application will be described clearly and completely below in conjunction with the embodiments. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0043] At present, the football games on the market are mainly card games. The movement control of non-player characters NPC in the game is usually very simple, such as controlling the players on the field to move without the ball or with the ball at a simple fixed distance. Some games are even simplified to the point where there is no referee and movement rules. This simple fixed-distance movement method causes players to always maintain a certain distance between each other, making the entire movement performance appear rigid, lacking randomness and flexibility, and unable to simulate the game and show a real football game.
[0044] Based on this, the embodiment of the present application provides a method, device and electronic device for controlling the movement of a character in a football game to solve the above problems. To facilitate understanding of the present embodiment, the method for controlling the movement of a character in a football game disclosed in the embodiment of the present application is first introduced in detail.
[0045] There are usually ordinary players, goalkeepers and referees in a football match; ordinary players also have their own identity attributes. For example, in the same football match, there will be forwards, midfielders, defenders, etc., and more specifically, there may be forwards, center forwards, left winger, right winger, attacking midfielder (central midfielder), midfielder, left midfielder, right midfielder, defensive midfielder, left wingback, right wingback, center back, left back, right back, and goalkeeper. For roles with different identity attributes, the target moving position that can be moved is determined in real time according to the current position of the football, and the movement is controlled based on the target moving position, which can improve the movement flexibility and randomness of roles with different identity attributes.
[0046] Figure 1 This is a flowchart of a method for controlling the movement of a character in a football game provided in an embodiment of the present application. The method comprises the following steps:
[0047] Step S102, obtaining the current position of the football in the game scene in the current control cycle and the identity attributes of each non-player controlled character NPC.
[0048] In a football game, the movement control of each NPC is a continuous cycle of control process, which is calculated and controlled once every preset time. Therefore, there will be multiple control cycles. In each control cycle, the current position of the football in the current control cycle and the identity attributes of each NPC will be obtained in real time to further determine the position it should move. The above identity attributes can be goalkeeper, referee, sideline referee, forward, center forward, left winger, right winger, attacking midfielder (central midfielder), midfielder, left midfielder, right midfielder, defensive midfielder, left wingback, right wingback, center back, left back, right back, etc.
[0049] Step S104, for each NPC, according to the current football position and the identity attribute of the NPC, determine the target moving position of the NPC in the current control cycle; the target moving position includes: a target moving point, a target moving track or a target moving area.
[0050] The movement of players in a football game is based on the movement of the football. Therefore, for each NPC, different calculations can be performed based on the current football position according to its different identity attributes to determine its target moving position in the current control cycle. The position can be a coordinate point, a trajectory line or an area.
[0051] Step S106, controlling the NPC to move within the game scene in the current control cycle according to the target moving position corresponding to the NPC.
[0052] If the target moving position is the target moving point, the NPC is controlled to move to the target moving point in the game scene in the current control cycle; if the target moving position is the target moving trajectory, the NPC is controlled to move along the target moving trajectory in the game scene in the current control cycle; if the target moving position is the target moving area, the NPC is controlled to move within the target moving area in the game scene in the current control cycle.
[0053] In the method for controlling the movement of characters in a football game provided in an embodiment of the present application, the current football position in the current control cycle and the identity attributes of each non-player controlled character NPC are first obtained; for each NPC, the target movement position of the NPC in the current control cycle is determined according to the current football position and the identity attributes of the NPC; the target movement position includes: a target movement point, a target movement trajectory or a target movement area; and the movement of the NPC is controlled according to the target movement position corresponding to the NPC. The embodiment of the present application can adopt different calculation methods according to the identity attributes of the character, determine the target movement position of the character based on the current football position, and control the character to move based on the target movement position, which can ensure the flexibility and randomness of its movement and improve the realism of the football game.
[0054] The embodiment of the present application also provides a method for controlling the movement of a character in a football game. This embodiment is implemented on the basis of the previous embodiment. This embodiment focuses on the process of determining the position of an ordinary player, which is as follows:
[0055] (1) If the identity attribute of the NPC is non-referee and non-goalkeeper, obtain the current state of the team to which the NPC belongs and the role position of the NPC in the previous control cycle; the current state includes the offensive state or the defensive state.
[0056] The current state can be determined by whether there is a ball-holding player in the team to which the NPC belongs. If so, it is an offensive state, and if not, it is a defensive state.
[0057] (2) Determine the target point corresponding to the NPC in the preset court dot matrix according to the identity attribute of the NPC;
[0058] Each point in the preset field dot matrix corresponds to a player with a specified identity attribute in a team formation. Figure 2 As shown, the points in the court include multiple evenly spaced points, such as 30 points in the figure. The 30 points cover the possible positions of players in various formations. Therefore, the corresponding target point among the 30 points can be determined according to the identity attributes of the character. Different points correspond to different position calculation methods.
[0059] (3) Determine the target moving point of the NPC in the current control cycle based on the current state, target point, current ball position and character position.
[0060] The above steps can be further implemented in the following ways:
[0061] A. Obtain the target designated line to which the target point belongs in the preset court dot matrix; each column of points in the above preset court dot matrix corresponds to a designated line; the preset court dot matrix corresponds to the back line, back waist line, midfield line, front waist line, forward line and center line from left to right; therefore, it can be determined which target designated line the target point corresponding to the NPC is located.
[0062] B. Calculate the coordinate components based on the ball coordinates corresponding to the current football position and the character coordinates corresponding to the character position. The ball coordinates and the character coordinates are both coordinates in a coordinate system with the center of the field as the origin. The field size is the World Cup standard field size: 105*68 (m), and the game will be presented in a 3D space, so the field coordinate system is defined as a 3D space coordinate system, the midpoint coordinate of the center circle of the field is (0,0,0), the left bottom line-right bottom line (horizontal direction) is the z axis, and the upper sideline-lower sideline (vertical direction) is the x axis. Since the ball generally moves on the ground, its y coordinate value can be regarded as 0, and only the z coordinate and x coordinate are concerned.
[0063] Subtract the z coordinate of the character coordinate from the z coordinate of the spherical coordinate to get the z-axis coordinate component;
[0064] Subtract the x-coordinate of the character coordinates from the x-coordinate of the spherical coordinates to get the x-axis coordinate component.
[0065] C. Determine the coordinate adjustment parameters corresponding to the character coordinates according to the current state, target designation line, coordinate components and spherical coordinates; the coordinate adjustment parameters include: coordinate offset value, coordinate offset coefficient and target coordinate value.
[0066] The target calculation rule set in the attack state is as follows:
[0067] 1. Offensive state
[0068] 1) Type: mode=1.
[0069] 2) Parameter settings:
[0070] Ball position: ballPos;
[0071] Ball coordinates: ballPos.x, 0, ballPos.z;
[0072] Target point middle value (A): adjustPos;
[0073] x-axis component (X): xDiscount = ballPos.x - adjustPos.x;
[0074] z-axis component (Z): zDiscount=ballPos.z-adjustPos.z;
[0075] x-axis offset coefficient (x);
[0076] z-axis offset coefficient (z);
[0077] Calculate auxiliary value T: tempzT (for correction);
[0078] The distance unit of the court movement is m;
[0079] Conventional target point moving coordinates: A = A + (X / 3.5, 0, Z / 2.6); x = 1.06, z = 1;
[0080] When the z-axis coordinate of the ball is less than 10: zuid>2z=0.8; zuid≤2; x=0.8;
[0081] zuid≥2, A=A+(Ax-0.12x,0,Az));
[0082] When the z-axis coordinate of the ball is ≥10: x=1.07;
[0083] zuid≥2,
[0084] zuid=2,A=Ax-0.12x.,0,Az+ballPos.z / 2.2;
[0085] zuid=3,A=Ax-0.12x.,0,Az+ballPos.z / 3.2;
[0086] zuid=4, A=0.01Ax*T.,0,Az+ballPos.z / 5; T=(100-ballPos.z)T≤75;
[0087] zuid=5,A=Ax-0.12x.,0,Az+ballPos.z / 9.8;
[0088] zuid=6, A=0.01Ax*T.,0,Az-ballPos.z / 28T=(100-ballPos.z)T≤55.
[0089] In the offensive state, if the target designated line is the back line, that is, zuid=1, the coordinate component is multiplied by the first preset coefficient to obtain the coordinate offset value corresponding to the character coordinates; such as the "conventional target point moving coordinates: A=A+(X / 3.5, 0, Z / 2.6)" in the above rule, (X / 3.5, 0, Z / 2.6) is the coordinate offset value.
[0090] If the target designated line is a non-defender line, and the Z value in the ball coordinates is less than the first threshold value (the first threshold value is 10 in this embodiment), the coordinate offset value corresponding to the character coordinates is determined according to the character coordinates, the coordinate components and the ball coordinates. Specifically, the x-coordinate of the character coordinates is subtracted from the product of the x-axis coordinate component and the second preset coefficient to obtain the x-axis coordinate offset value corresponding to the character coordinates; the z-coordinate of the character coordinates is used as the z-axis coordinate offset value corresponding to the character coordinates. As in the above rule "When the z-axis coordinate of the ball is <10, zuid≥2, A=A+(Ax-0.12x,0,Az))", Ax-0.12x is the x-axis coordinate offset value, and Az is the z-axis coordinate offset value; wherein Ax is the x-coordinate of the character coordinates; -0.12x is the product of the second preset coefficient -0.12 and the x-axis coordinate component.
[0091] If the target designation line is not a back line, and the Z value in the ball coordinates is greater than or equal to the first threshold, the coordinate offset value or coordinate offset coefficient corresponding to the character coordinates is determined according to the target designation line, the coordinate components, and the ball coordinates. For example, in the above rule, "When the z-axis coordinate of the ball is ≥ 10: x = 1.07;
[0092] zuid≥2,
[0093] zuid=2,A=Ax-0.12x.,0,Az+ballPos.z / 2.2;
[0094] zuid=3,A=Ax-0.12x.,0,Az+ballPos.z / 3.2;
[0095] zuid=4, A=0.01Ax*T.,0,Az+ballPos.z / 5; T=(100-ballPos.z)T≤75;
[0096] zuid=5,A=Ax-0.12x.,0,Az+ballPos.z / 9.8;
[0097] zuid=6, A=0.01Ax*T.,0,Az-ballPos.z / 28T=(100-ballPos.z)T≤55. "
[0098] Specifically, the z-axis coordinate offset value corresponding to the character coordinate is obtained by multiplying the z-coordinate in the spherical coordinates by the specified coefficient corresponding to the target specified line; for example, when zuid=2, the z-axis coordinate offset value is ballPos.z / 2.2; when zuid=3, the z-axis coordinate offset value is ballPos.z / 3.2; when zuid=4, the z-axis coordinate offset value is ballPos.z / 5; when zuid=5, the z-axis coordinate offset value is ballPos.z / 9.8; when zuid=6, the z-axis coordinate offset value is ballPos.z / 28.
[0099] If the target designated line is the front waist line (zuid=4) or the center line (zuid=6), determine the first correction value according to the z coordinate in the ball coordinates, and multiply the first correction value by the third preset coefficient to obtain the x-axis coordinate offset coefficient corresponding to the character coordinates; as mentioned above 0.01Ax*T, 0.01T is the x-axis coordinate offset coefficient, T is the first correction value, T=(100-ballPos.z).
[0100] If the target designated line is the back waist line (zuid=2), the midfield line (zuid=3) or the forward line (zuid=5), the x-axis coordinate component is multiplied by the fourth preset coefficient to obtain the x-axis coordinate offset value corresponding to the character coordinate. For example, -0.12x is the x-axis coordinate offset value; -0.12x is the product of the fourth preset coefficient -0.12 and the x-axis coordinate component.
[0101] The goal calculation rules in the defensive state are as follows:
[0102] 1) Type: mode = 2.
[0103] 2) Parameter settings:
[0104] Conventional target point moving coordinates: A=A+(X / 3.5, 0, Z / 1.8);
[0105] tempzT=ballPos.z:x=1,z=1;
[0106] When the z-axis coordinate of the ball is greater than 20, tempzT=2;
[0107] -35<When the z-axis coordinate of the ball is <20, tempzT=2-(20-ballPos.z)*0.58f;
[0108] -42<When the z-axis coordinate of the ball is <-35, tempzT=2-(20+35)*0.58f;
[0109] When the z-axis coordinate of the ball is <-42, tempzT=2-(18-ballPos.z)*0.58f;
[0110] tempXidcut=Mathf.Abs(singleUnit.xUid-3), take the absolute value, the absolute value of |id-3| of each point in each row;
[0111] zuid<5,x=0.8;
[0112] zuid=1, when the z-axis coordinate of the ball is <-20, tempzT=tempzT-tempzT*0.11f; adjustPos=adjustPos.x*(0.7f+tempXidcut*0.18f)+xDiscount*0.22f, 0, tempzT-16;
[0113] zuid=2, when the z-axis coordinate of the ball<-20, tempzT=tempzT-tempzT*0.11f; tempXidcut<1.2ftempXidcut=1.2f; adjustPos=adj ustPos.x*(1f+tempXidcut*0.1f)+xDiscount*0.16f*(2-tempXidcut),0,tempzT-(9+tempXidcut*3.2f);
[0114] zuid=3, when the z-axis coordinate of the ball is <-20, tempzT=tempzT+tempzT*0.08f; adjustPos=adjustPos.x*(0.7f+tempXidcut*0.18f)+xDiscount*0.22f, 0, tempzT-4;
[0115] zuid=4, when the z-axis coordinate of the ball is <-20, tempzT=tempzT+tempzT*0.05f; tempXidcut<1.2f, tempXidcut=1.2f; adjustPos=ad justPos.x*(1f+tempXidcut*0.1f)+xDiscount*0.16f*(2-tempXidcut),0,tempzT-(tempXidcut*3.2f-3);
[0116] zuid=5, when the z-axis coordinate of the ball is <0, tempzT=tempzT*0.6f; when the z-axis coordinate of the ball is >30, tempzT=30, adjustPos=adjustPos.x*0.9f,0, tempzT-3;
[0117] zuid=6, when the z-axis coordinate of the ball is <0, tempzT=tempzT*0.3f; when the z-axis coordinate of the ball is >30, tempzT=30; adjustPos=adjustPos.x,0,tempzT+2.
[0118] 1) If the current state is the defensive state, determine the target correction value according to the ball coordinates and the target designation line; specifically, determine the initial correction value according to the target designation interval where the z coordinate of the ball coordinates is located; different designation intervals correspond to different correction calculation formulas; such as in the above rules "when the z-axis coordinate of the ball is greater than 20, tempzT=2; -35< when the z-axis coordinate of the ball is less than 20, tempzT=2-(20-ballPos.z)*0.58f; -42< when the z-axis coordinate of the ball is less than -35, tempzT=2-(20+35)*0.58f; when the z-axis coordinate of the ball is less than -42, tempzT=2-(18-ballPos.z)*0.58f;"
[0119] The target correction value is determined based on the relationship between the initial correction value and the threshold value corresponding to the z coordinate and the target designation line. For example, in the above rules, "zuid=1, when the z-axis coordinate of the ball is <-20, tempzT=tempzT-tempzT*0.11f; zuid=2, when the z-axis coordinate of the ball is <-20, tempzT=tempzT-tempzT*0.11f; uid=3, when the z-axis coordinate of the ball is <-20, tempzT=tempzT+tempzT*0.08f; zuid=4, when the z-axis coordinate of the ball is <-20, tempzT=tempzT+tempzT*0.05f; zuid=5, when the z-axis coordinate of the ball is <0, tempzT=tempzT*0.6f; when the z-axis coordinate of the ball is >30, tempzT=30; zuid=6, when the z-axis coordinate of the ball is <0, tempzT=tempzT*0.3f; when the z-axis coordinate of the ball is >30, tempzT=30;"
[0120] 2) Determine the z-axis target coordinate value corresponding to the character coordinates according to the target correction value; such as in the above rule "when zuid=1, the z-axis target coordinate value is tempzT-16; tempzT is the target correction value; when zuid=2, the z-axis target coordinate value is tempzT-(9+tempXidcut*3.2f); when zuid=3, the z-axis target coordinate value is tempzT-4; when zuid=4, the z-axis target coordinate value is tempzT-(tempXidcut*3.2f-3); when zuid=5, the z-axis target coordinate value is tempzT-3; when zuid=6, the z-axis target coordinate value is tempzT+2". Among them, tempXidcut is the identification related value, that is, "the absolute value of id-3", and f is the movement unit, usually 0.2f per frame.
[0121] 3) If the target designated line is the back line, back waist line, midfield line or front waist line, determine the x-axis coordinate offset coefficient corresponding to the character coordinates according to the identification-related value corresponding to the target designated line; determine the x-axis coordinate offset value corresponding to the character coordinates according to the x-axis coordinate component of the coordinate component; such as in the above rule "when zuid=1, the x-axis coordinate offset coefficient is (0.7f+tempXidcut*0.18f); the x-axis coordinate offset value is xDiscount*0.22f; when zuid=2, the x-axis coordinate offset coefficient is (1f+tempXidcut*0.18f); cut*0.1f); the x-axis coordinate offset value is xDiscount*0.16f*(2-tempXidcut); when zuid=3, the x-axis coordinate offset coefficient is (0.7f+tempXidcut*0.18f); the x-axis coordinate offset value is xDiscount*0.22f; when zuid=4, the x-axis coordinate offset coefficient is (1f+tempXidcut*0.1f); the x-axis coordinate offset value is xDiscount*0.16f*(2-tempXidcut)".
[0122] If the target designated line is the forward line or the center line, the preset value is determined as the x-axis offset coefficient corresponding to the character coordinates. For example, "when zuid=5, the x-axis offset coefficient is 0.9f; when zuid=6, the x-axis offset coefficient is 1" as mentioned above.
[0123] D. Based on the coordinate adjustment parameters, the character coordinates are adjusted to obtain the target moving point of the NPC in the current control cycle.
[0124] If the coordinate adjustment parameters include a coordinate offset value, sum the character coordinates with the coordinate offset value; if the coordinate adjustment parameters include a coordinate offset coefficient, multiply the character coordinates with the coordinate offset coefficient; if the coordinate adjustment parameters include a coordinate offset coefficient and a coordinate offset value, multiply the character coordinates with the coordinate offset coefficient and sum the obtained product with the coordinate offset value; if the coordinate adjustment parameters include a target coordinate value, use the target coordinate value to update the character coordinates.
[0125] The character movement control method in the football game provided by the embodiment of the present application can determine the corresponding target movement point based on different calculation rules for the current state of the team to which the NPC belongs, its position in the field dot matrix, and the current football position and character position when the NPC is an ordinary player. Then, the target movement point in the current control cycle is further determined, and the NPC is controlled to move to the target movement point, thereby improving the movement flexibility and randomness of ordinary players in the football game and improving the authenticity of the game.
[0126] The embodiment of the present application also provides a method for controlling the movement of a character in a football game. This embodiment is implemented on the basis of the first method embodiment. This embodiment focuses on the process of determining the position of the goalkeeper, which is as follows:
[0127] (1) If the NPC's identity attribute is goalkeeper, obtain the corresponding role position of the NPC in the previous control cycle;
[0128] (2) Calculate the first distance between the ball and the NPC based on the current ball position and the character position;
[0129] (3) Determine whether there is an opposing player in a first designated area based on the position of the character; the first designated area may be a circular area with the position of the character as the center and a preset radius, or a rectangular area with the line where the position of the character is located as a side of the rectangle. Usually, the first designated area is an area that includes the ball.
[0130] (4) If yes, determine the target movement trajectory corresponding to the NPC based on the first distance; if there is an opponent player in the first designated area based on the character position, then the goalkeeper can make a defensive move, so it is necessary to determine the target movement trajectory of the goalkeeper.
[0131] Specifically, the second distance between the NPC and the center of the goal is determined based on the first distance; the second distance is positively correlated with the first distance; that is, the greater the distance between the football and the goalkeeper, the greater the distance between the goalkeeper and the center of the goal. In a preferred embodiment, the target distance segment corresponding to the first distance can be found from the preset distance correspondence relationship; the target distance corresponding to the target distance segment is determined as the second distance between the NPC and the center of the goal. Figure 3 It can be seen from the table that the preset distance correspondence includes: the correspondence between the distance segment between the football and the goalkeeper, and the distance between the goalkeeper and the center of the goal; therefore, the target distance segment corresponding to the first distance can be found, and then the target distance can be found.
[0132] After determining the second distance between the NPC and the goal center, further determine the two intersection points of a circle with the target moving point as the center and the second distance as the radius and the large penalty area; Figure 4 As shown, the target moving point is: on a vertical line passing through the center of the goal and perpendicular to the side of the goal away from the court, the distance from the center of the goal is half the length of the goal, as shown in the center of the circle in the figure.
[0133] Finally, the arc between the two intersection points is determined as the target moving trajectory corresponding to the NPC, such as Figure 4 The dashed arc in .
[0134] It should be noted that Figure 3The setting of the distance between the goalkeeper and the center of the goal in the table shown needs to meet certain requirements to ensure that the moving trajectory of the goalkeeper does not exceed the preset moving area, and the preset moving area includes: the area enclosed by two arcs formed in the court with the target moving point as the center, the distance between the target moving point and the corner point of the goal as the first radius, and the distance between the target moving point and the corner point of the large penalty area as the second radius; Figure 4 The fan-shaped area enclosed by the largest circle and the smallest circle in the court area.
[0135] (5) If not, determine the target moving area corresponding to the NPC based on the first distance.
[0136] Specifically, a second designated area based on the first distance is determined; and the second designated area is determined as the NPC corresponding target movement area so that the NPC can attack.
[0137] See also Figure 5 As shown, when there is no defensive player in the designated range in front of the goalkeeper, and the opponent's player with the ball is at the attacking distance with the goalkeeper (i.e. a one-on-one situation, a through ball, or a high ball), the goalkeeper will attack; the attacking distance is related to the goalkeeping attributes of the goalkeeper himself, such as the goalkeeper's position and reaction.
[0138] In order to more accurately control the movement of the players, the above method also includes the following steps: obtaining the current speed of the football, and the third distance between the character position and the target moving position; determining the movement rate of the NPC based on the current speed and the third distance; and controlling the movement of the NPC based on the movement rate and the target moving position.
[0139] The character movement control method in the football game provided by the embodiment of the present application can determine the target movement trajectory or target movement area corresponding to the NPC according to the distance between the current football position and the character position and the situation of the defensive players within the specified range when the NPC is the goalkeeper. Therefore, the movement of the goalkeeper in the football game is more consistent with the real football game scene, and the authenticity of the game is improved.
[0140] The embodiment of the present application also provides a method for controlling the movement of a character in a football game. This embodiment is implemented on the basis of the first method embodiment. This embodiment focuses on describing the process of determining the position of the referee, which is as follows:
[0141] (1) If the identity attribute of the NPC is the referee, obtain the current state of the NPC; the referee's running position is divided into two states: the regular state and the set-piece state. The regular state is the referee's running position during the game, and the set-piece state is the referee's position when the game is in progress, such as the midfield kick-off, corner kick, free kick, penalty kick, or out-of-bounds kick.
[0142] (2) determining whether the current state is a designated penalty kick state; the designated penalty kick state includes one of the following: a corner kick state, a midfield kick state, and a penalty kick state;
[0143] (3) If yes, the preset position is determined as the target moving point corresponding to the NPC.
[0144] 1) Corner kick status: When taking a corner kick, the referee stands at a fixed position at both ends of the penalty area, with coordinates of p(z,x) = (-36, 20.16) / (-36, -20.16) / (36, 20.16) / (36, -20.16).
[0145] 2) Kick-off at midfield: When the kick-off is at midfield, the referee stands in the center circle (the referee stands in the center circle of the half of the field where the kick-off is). The position is fixed, 45° away from the center point and 9 meters away. The coordinates are p(z,x) = (-6.4,6.4) / (6.4,-6.4).
[0146] 3) Penalty kick: When taking a penalty kick, the referee stands at the end points on both sides of the small penalty area, with coordinates of p(z,x)=(-28.5,-5.5) / (28.5,5.5).
[0147] (4) If not, determine the positional relationship between the football and the target diagonal based on the current football position; the target diagonal is the diagonal obtained by connecting the two diagonal points of the two large penalty areas; based on the positional relationship and the current football position, determine the target moving point corresponding to the NPC.
[0148] Case 1: If the position relationship is that the ball is on the diagonal line of the target, determine a circle with the current ball position as the center and the preset distance as the radius; determine the specified point on the circle as the target moving point corresponding to the NPC. Figure 6 As shown, the preset distance is 2 meters, and the designated point is the position point of "P" on the circle. The designated point on the circle can be a point at a preset distance from the target diagonal line, and the preset distance can be adjusted according to actual conditions.
[0149] In the second case, if the position relationship is that the perpendicular line between the football and the target diagonal passes through the target diagonal, calculate the vertical distance between the football and the target diagonal; determine the target moving point corresponding to the NPC on the vertical line segment corresponding to the vertical distance according to the vertical distance. Specifically, reduce the vertical distance by a preset ratio to obtain the target distance; determine the target moving point with a distance from the target diagonal equal to the target distance on the vertical line segment corresponding to the vertical distance; determine the target moving point corresponding to the NPC according to the target moving point. See Figure 6As shown, the target moving point is the point "P" between the vertical line segment of the football and the target diagonal. The referee runs at a certain coordinate on the vertical line between the football position and the diagonal, so the referee's running trajectory in the game is a wave curve. The coordinate is calculated according to the length of the vertical line, and each logic needle is calculated once; the distance range of the vertical line is: 0-53m, and the maximum distance is the vertical line from the diagonal point of the court to the diagonal; the referee's running distance calculation: P = P1*0.2 (configurable), P is the distance from the referee to the diagonal, P1 is the distance from the football to the diagonal, and the referee moves at the coordinate point at the vertical distance of 0.2P1 from the diagonal.
[0150] Furthermore, the above step of determining the target moving point corresponding to the NPC according to the target moving point includes the following two cases: if the target moving point is in the restricted area, the intersection of the vertical line segment and the large restricted area is used as the target moving point corresponding to the NPC, see Figure 7 As shown in the figure, if the position of "P" is in the penalty area, the position of "P" is adjusted to the intersection of the vertical line segment and the large penalty area. This setting method corresponds to the principle of outside the penalty area in football matches: in regular matches, the referee generally does not enter the penalty area to run (the density of people in the penalty area is high), so when the referee's target moving point is calculated to be in the penalty area, it will move at the intersection of the vertical line and the penalty area. If the target moving point is not in the penalty area, the target moving point determined above is used as the target moving point corresponding to the NPC.
[0151] In the third case, if the position relationship is that the perpendicular line between the football and the target diagonal passes through the extended line of the target diagonal, determine the perpendicular line segment between the football and the extended line of the target diagonal; determine the target perpendicular line segment that passes through the diagonal point of the penalty area and is parallel to the perpendicular line segment; determine the target moving point corresponding to the NPC on the target perpendicular line segment, see Figure 8 As shown, when the football is not within the diagonal range, a parallel line to the diagonal is drawn according to the position of the ball, and the referee moves to the target position where the football is at the coordinates of the intersection of the diagonal point and the parallel line.
[0152] If the NPC's identity attribute is a sideline referee, determine the intersection of the vertical line between the second-to-last player and the sideline and the sideline in the half where the NPC is located; determine the intersection as the target moving point corresponding to the NPC.
[0153] 1) There are two touchline referees in every game, always running along the touchline of their respective half;
[0154] 2) The linesman moves at the coordinate point where the second to last player (the penultimate player is the goalkeeper) and the sideline intersect vertically;
[0155] 3) The linesman does not make any special arrangements for the positions of both teams when taking a free kick, and the linesman still follows the second rule for his positions.
[0156] The method for controlling the movement of a character in a football game provided by the embodiment of the present application can determine the target movement point corresponding to the NPC according to some rules of the football game and the current state of the NPC when the NPC is the referee, thereby making the movement of the referee in the football game more consistent with the real football game scene and improving the authenticity of the game.
[0157] Based on the above method embodiment, the present application embodiment also provides a character movement control device in a football game, see Fig. 9 As shown, the device includes: a data acquisition module 92, which is used to obtain the current football position in the game scene in the current control cycle and the identity attributes of each non-player controlled character NPC; a position determination module 94, which is used to determine the target moving position of the NPC in the current control cycle for each NPC according to the current football position and the identity attributes of the NPC; the target moving position includes: a target moving point, a target moving trajectory or a target moving area; a movement control module 96, which is used to control the movement of the NPC in the game scene in the current control cycle according to the target moving position corresponding to the NPC.
[0158] The character movement control device in the football game provided by the embodiment of the present application can determine the target movement position of the character according to the identity attributes of the character and the current position of the football, and control the character to move based on the target movement position, thereby ensuring the flexibility and randomness of its movement and improving the realism of the football game.
[0159] The above-mentioned position determination module 94 is also used to obtain the current state of the team to which the NPC belongs and the character position of the NPC in the previous control cycle if the identity attribute of the NPC is non-referee and non-goalkeeper; the current state includes an offensive state or a defensive state; according to the identity attribute of the NPC, the target point corresponding to the NPC in the preset stadium dot matrix is determined; each point in the preset stadium dot matrix corresponds to a player with a specified identity attribute in a team formation; according to the current state, target point, current football position and character position, the target moving point of the NPC in the current control cycle is determined.
[0160] Each column of points in the above-mentioned preset court dot matrix corresponds to a designated line; the preset court dot matrix corresponds to the back line, back waist line, midfield line, front waist line, forward line and center line from left to right; the above-mentioned position determination module 94 is also used to obtain the target designated line to which the target point belongs in the preset court dot matrix; calculate the coordinate components according to the ball coordinates corresponding to the current football position and the character coordinates corresponding to the character position; determine the coordinate adjustment parameters corresponding to the character coordinates according to the current state, the target designated line, the coordinate components and the ball coordinates; the coordinate adjustment parameters include: coordinate offset value, coordinate offset coefficient and target coordinate value; based on the coordinate adjustment parameters, adjust the character coordinates to obtain the target moving point of the NPC in the current control cycle.
[0161] The above-mentioned position determination module 94 is also used to, if the current state is an offensive state and the target designated line is a back line, multiply the coordinate component by a first preset coefficient to obtain a coordinate offset value corresponding to the character coordinates; if the target designated line is a non-back line and the Z value in the spherical coordinates is less than a first threshold, determine the coordinate offset value corresponding to the character coordinates according to the character coordinates, the coordinate component and the spherical coordinates; if the target designated line is a non-back line and the Z value in the spherical coordinates is greater than or equal to the first threshold, determine the coordinate offset value or coordinate offset coefficient corresponding to the character coordinates according to the target designated line, the coordinate component and the spherical coordinates.
[0162] The above-mentioned position determination module 94 is also used to subtract the product of the x-axis coordinate component and the second preset coefficient from the x-coordinate of the character coordinate to obtain the x-axis coordinate offset value corresponding to the character coordinate; and use the z-coordinate of the character coordinate as the z-axis coordinate offset value corresponding to the character coordinate.
[0163] The above-mentioned position determination module 94 is also used to multiply the z-coordinate in the spherical coordinates by the specified coefficient corresponding to the target designated line to obtain the z-axis coordinate offset value corresponding to the character coordinates; if the target designated line is the front waist line or the center line, determine the first correction value according to the z-coordinate in the spherical coordinates, and multiply the first correction value by the third preset coefficient to obtain the x-axis coordinate offset coefficient corresponding to the character coordinates; if the target designated line is the back waist line, the midfield line or the forward line, multiply the x-axis coordinate component by the fourth preset coefficient to obtain the x-axis coordinate offset value corresponding to the character coordinates.
[0164] The above-mentioned position determination module 94 is also used to determine the target correction value according to the ball coordinates and the target designated line if the current state is a defensive state; determine the z-axis coordinate offset value corresponding to the character coordinates according to the target correction value; if the target designated line is the back line, the back waist line, the midfield line or the front waist line, determine the x-axis coordinate offset coefficient corresponding to the character coordinates according to the identification-related value corresponding to the target designated line; determine the x-axis coordinate offset value corresponding to the character coordinates according to the x-axis coordinate component of the coordinate component; if the target designated line is the forward line or the center line, determine the preset value as the x-axis offset coefficient corresponding to the character coordinates.
[0165] The above-mentioned position determination module 94 is also used to determine the initial correction value according to the target specified interval where the z coordinate of the spherical coordinates is located; different specified intervals correspond to different correction calculation formulas; the target correction value is determined based on the initial correction value and the relationship between the z coordinate and the threshold corresponding to the target specified line.
[0166] The above-mentioned position determination module 94 is also used to sum the character coordinates with the coordinate offset value if the coordinate adjustment parameters include a coordinate offset value; multiply the character coordinates with the coordinate offset coefficient if the coordinate adjustment parameters include a coordinate offset coefficient; multiply the character coordinates with the coordinate offset coefficient if the coordinate adjustment parameters include a coordinate offset coefficient and a coordinate offset value, and sum the obtained product with the coordinate offset value; if the coordinate adjustment parameters include a target coordinate value, update the character coordinates using the target coordinate value.
[0167] The above-mentioned position determination module 94 is also used to obtain the character position corresponding to the NPC in the previous control cycle if the identity attribute of the NPC is a goalkeeper; calculate the first distance between the football and the NPC based on the current football position and the character position; determine whether there is an opponent player in the first designated area based on the character position; if yes, determine the target movement trajectory corresponding to the NPC based on the first distance; if not, determine the target movement area corresponding to the NPC based on the first distance.
[0168] The above-mentioned position determination module 94 is also used to determine the second distance between the NPC and the center of the goal based on the first distance; the second distance is positively correlated with the first distance; determine two intersection points of a circle with the target moving point as the center and the second distance as the radius and the large penalty area; wherein the target moving point is: a point on a vertical line passing through the center of the goal and perpendicular to the side of the goal away from the court, the distance from the center of the goal is half the length of the goal; the arc between the two intersection points is determined as the target moving trajectory corresponding to the NPC.
[0169] The above-mentioned position determination module 94 is also used to find the target distance segment corresponding to the first distance from the preset distance correspondence relationship; the preset distance correspondence relationship includes: the correspondence between the distance segment between the football and the goalkeeper, and the distance between the goalkeeper and the center of the goal; the target distance corresponding to the target distance segment is determined as the second distance between the NPC and the center of the goal.
[0170] The above-mentioned position determination module 94 is also used to determine a second designated area based on the first distance; and determine the second designated area as the NPC corresponding target movement area so that the NPC can attack.
[0171] The above-mentioned movement control module 96 is also used to obtain the current speed of the football and the third distance between the character position and the target moving position; determine the movement rate of the NPC according to the current speed and the third distance; and control the movement of the NPC according to the movement rate and the target moving position.
[0172] The above-mentioned position determination module 94 is also used to obtain the current state of the NPC if the identity attribute of the NPC is the referee; determine whether the current state is a designated penalty kick state; the designated penalty kick state includes one of the following: corner kick state, midfield kick-off state and penalty kick state; if yes, determine the preset position as the target moving point corresponding to the NPC; if not, determine the position relationship between the football and the target diagonal according to the current football position; the target diagonal is the diagonal obtained by connecting the two diagonal points of the two large penalty areas; determine the target moving point corresponding to the NPC according to the position relationship and the current football position.
[0173] The position determination module 94 is also used to determine a circle with the current position of the football as the center and a preset distance as the radius if the position relationship is that the football is on the target diagonal line; and determine a specified point on the circle as the target moving point corresponding to the NPC.
[0174] The above-mentioned position determination module 94 is also used to calculate the vertical distance between the football and the target diagonal if the position relationship is that the perpendicular line between the football and the target diagonal passes through the target diagonal; according to the vertical distance, determine the target moving point corresponding to the NPC on the vertical line segment corresponding to the vertical distance.
[0175] The above-mentioned position determination module 94 is also used to reduce the vertical distance according to a preset ratio to obtain the target distance; determine the target moving point whose diagonal distance from the target is the target distance on the vertical line segment corresponding to the vertical distance; and determine the target moving point corresponding to the NPC based on the target moving point.
[0176] The above-mentioned position determination module 94 is also used to determine whether the target moving point is in the restricted area; if so, the intersection of the vertical line segment and the large restricted area is used as the target moving point corresponding to the NPC; if not, the target moving point is used as the target moving point corresponding to the NPC.
[0177] The above-mentioned position determination module 94 is also used to determine the vertical line segment of the extension line of the diagonal line of the football and the target if the position relationship is that the vertical line of the diagonal line of the football and the target passes through the extension line of the diagonal line of the target; determine the target vertical line segment that passes through the diagonal point of the penalty area and is parallel to the vertical line segment; and determine the target moving point corresponding to the NPC on the target vertical line segment.
[0178] The position determination module 94 is also used to determine the intersection of the vertical line between the second-to-last player and the sideline and the sideline in the half where the NPC is located if the identity attribute of the NPC is a sideline referee; and determine the intersection as the target moving point corresponding to the NPC.
[0179] The above-mentioned mobile control module 96 is also used to control the NPC to move to the target moving point in the game scene in the current control cycle if the target moving position includes: a target moving point; if the target moving position includes: a target moving trajectory, control the NPC to move along the target moving trajectory in the game scene in the current control cycle; if the target moving position includes: a target moving area, control the NPC to move within the target moving area in the game scene in the current control cycle.
[0180] The device provided in the embodiment of the present application has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the embodiment of the device, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0181] The present application also provides an electronic device, such as Fig.10 As shown, it is a schematic diagram of the structure of the electronic device, wherein the electronic device includes a processor 101 and a memory 100, the memory 100 stores computer executable instructions that can be executed by the processor 101, and the processor 101 executes the computer executable instructions to implement the above method.
[0182] exist Fig.10 In the illustrated embodiment, the electronic device further includes a bus 102 and a communication interface 103 , wherein the processor 101 , the communication interface 103 and the memory 100 are connected via the bus 102 .
[0183] Among them, the memory 100 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which can be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. can be used. The bus 102 can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 102 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.10 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0184] The processor 101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 101. The above processor 101 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or the hardware and software modules in the decoding processor can be combined and performed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor 101 reads the information in the memory and completes the steps of the method of the above embodiment in combination with its hardware.
[0185] An embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above method. The specific implementation can be found in the aforementioned method embodiment, which will not be repeated here.
[0186] The computer program products of the methods, devices, and electronic devices provided in the embodiments of the present application include a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be found in the method embodiments, which will not be repeated here.
[0187] Unless otherwise specifically stated, the relative steps, numerical expressions and values of the components and steps set forth in these embodiments do not limit the scope of the present application.
[0188] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0189] In the description of the present application, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present application. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0190] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A method for controlling the movement of a character in a football game, characterized in that: The method comprises: Get the current football position in the game scene in the current control cycle and the identity attributes of each non-player controlled character NPC; For each NPC, according to the current football position and the identity attribute of the NPC, the target moving position of the NPC in the current control cycle is determined; the target moving position includes: a target moving point, a target moving track or a target moving area; According to the target moving position corresponding to the NPC, controlling the NPC to move within the game scene in the current control cycle; The step of determining the target moving position of the NPC in the current control cycle according to the current football position and the identity attribute of the NPC includes: If the identity attribute of the NPC is non-referee and non-goalkeeper, obtain the current state corresponding to the team to which the NPC belongs and the role position corresponding to the NPC in the previous control cycle; the current state includes an offensive state or a defensive state; determine the target point corresponding to the NPC in the preset court dot matrix according to the identity attribute of the NPC; each point in the preset court dot matrix corresponds to a player with a specified identity attribute in a team formation; each column of points in the preset court dot matrix corresponds to a designated line; the preset court dot matrix corresponds to the back line, the back waist line, the midfield line, the front waist line, the forward line and the center line from left to right; obtain the target designated line to which the target point belongs in the preset court dot matrix; calculate the coordinate components according to the ball coordinates corresponding to the current football position and the role coordinates corresponding to the role position; determine the coordinate adjustment parameters corresponding to the role coordinates according to the current state, the target designated line, the coordinate components and the ball coordinates; the coordinate adjustment parameters include: a coordinate offset value, a coordinate offset coefficient and a target coordinate value; based on the coordinate adjustment parameters, adjust the character coordinates to obtain the target moving point of the NPC in the current control cycle.
2. The method according to claim 1, characterized in that The step of determining the coordinate adjustment parameters corresponding to the character coordinates according to the current state, the target designation line, the coordinate components and the spherical coordinates comprises: If the current state is an attacking state, the target designated line is a back line, and the coordinate component is multiplied by a first preset coefficient to obtain a coordinate offset value corresponding to the character coordinate; If the target designated line is a non-defender line and the Z value in the spherical coordinates is less than a first threshold, determining a coordinate offset value corresponding to the character coordinates according to the character coordinates, the coordinate components and the spherical coordinates; If the target designation line is a non-defender line and the Z value in the spherical coordinates is greater than or equal to the first threshold, the coordinate offset value or coordinate offset coefficient corresponding to the character coordinates is determined according to the target designation line, the coordinate components and the spherical coordinates.
3. The method according to claim 2, characterized in that The step of determining the coordinate offset value corresponding to the character coordinate according to the character coordinate, the coordinate component and the spherical coordinate comprises: Subtracting the product of the x-axis coordinate component and the second preset coefficient from the x-coordinate of the character coordinate to obtain the x-axis coordinate offset value corresponding to the character coordinate; The z coordinate of the character coordinates is used as the z-axis coordinate offset value corresponding to the character coordinates.
4. The method according to claim 2, characterized in that: The step of determining the coordinate offset value or coordinate offset coefficient corresponding to the character coordinates according to the target designation line, the coordinate components and the spherical coordinates comprises: Multiplying the z coordinate in the spherical coordinates by the specified coefficient corresponding to the target specified line to obtain the z-axis coordinate offset value corresponding to the character coordinates; If the target designated line is the front waist line or the center forward line, determine a first correction value according to the z coordinate in the ball coordinates, and multiply the first correction value by a third preset coefficient to obtain an x-axis coordinate offset coefficient corresponding to the character coordinates; If the target designated line is the back waist line, the midfield line or the forward line, the x-axis coordinate component is multiplied by the fourth preset coefficient to obtain the x-axis coordinate offset value corresponding to the character coordinate.
5. The method according to claim 1, characterized in that The step of determining the coordinate adjustment parameters corresponding to the character coordinates according to the current state, the target designation line, the coordinate components and the spherical coordinates comprises: If the current state is a defensive state, determining a target correction value according to the ball coordinates and the target designation line; Determine the z-axis target coordinate value corresponding to the character coordinate according to the target correction value; If the target designated line is the back line, the back waist line, the midfield line or the front waist line, determine the x-axis coordinate offset coefficient corresponding to the character coordinates according to the identifier-related value corresponding to the target designated line; determine the x-axis coordinate offset value corresponding to the character coordinates according to the x-axis coordinate component of the coordinate component; If the target designated line is the forward line or the center line, the preset value is determined as the x-axis offset coefficient corresponding to the character coordinates.
6. The method according to claim 5, characterized in that The step of determining the target correction value according to the spherical coordinates and the target designation line comprises: Determine an initial correction value according to a target designated interval where the z coordinate of the spherical coordinates is located; different designated intervals correspond to different correction calculation formulas; A target correction value is determined based on the initial correction value and the relationship between the z coordinate and the threshold value corresponding to the target designation line.
7. The method according to claim 1, characterized in that The step of adjusting the character coordinates based on the coordinate adjustment parameters includes: If the coordinate adjustment parameter includes a coordinate offset value, summing the character coordinates and the coordinate offset value; If the coordinate adjustment parameter includes a coordinate offset coefficient, multiplying the character coordinates by the coordinate offset coefficient; If the coordinate adjustment parameter includes a coordinate offset coefficient and a coordinate offset value, multiplying the character coordinates by the coordinate offset coefficient, and summing the obtained product with the coordinate offset value; If the coordinate adjustment parameters include a target coordinate value, the character coordinates are updated using the target coordinate value.
8. The method according to claim 1, characterized in that The step of determining the target moving position of the NPC in the current control cycle according to the current football position and the identity attribute of the NPC includes: If the identity attribute of the NPC is goalkeeper, obtain the corresponding role position of the NPC in the previous control cycle; Calculate a first distance between the football and the NPC according to the current football position and the character position; Determining whether there is an opposing player in a first designated area based on the position of the character; If yes, determining the target movement trajectory corresponding to the NPC according to the first distance; If not, determine the target moving area corresponding to the NPC according to the first distance.
9. The method according to claim 8, characterized in that The step of determining the target movement trajectory corresponding to the NPC according to the first distance includes: Determine a second distance between the NPC and the goal center according to the first distance; the second distance is positively correlated with the first distance; Determine two intersection points of a circle with the target moving point as the center and the second distance as the radius and the large penalty area; wherein the target moving point is: a point on a vertical line passing through the center of the goal and perpendicular to the side of the goal away from the court, the distance from the center of the goal being half the length of the goal; The arc between the two intersection points is determined as the target movement trajectory corresponding to the NPC.
10. The method according to claim 9, characterized in that The step of determining a second distance between the NPC and the goal center according to the first distance comprises: Find the target distance segment corresponding to the first distance from the preset distance correspondence relationship; the preset distance correspondence relationship includes: the distance segment between the football and the goalkeeper, and the correspondence relationship between the goalkeeper and the center of the goal; The target distance corresponding to the target distance segment is determined as the second distance between the NPC and the center of the goal.
11. The method according to claim 8, characterized in that The step of determining the target moving area corresponding to the NPC according to the first distance includes: determining a second designated area based on the first distance; The second designated area is determined as the target movement area corresponding to the NPC so that the NPC can attack.
12. The method according to claim 8, characterized in that The method further comprises: Obtaining the current speed of the football and a third distance between the character position and the target moving position; Determine the movement rate of the NPC according to the current speed and the third distance; The NPC is controlled to move according to the moving speed and the target moving position.
13. The method according to claim 1, characterized in that The step of determining the target moving position of the NPC in the current control cycle according to the current football position and the identity attribute of the NPC includes: If the identity attribute of the NPC is the referee, obtain the current state of the NPC; Determine whether the current state is a designated penalty kick state; the designated penalty kick state includes one of the following: a corner kick state, a midfield kick state, and a penalty kick state; If yes, the preset position is determined as the target moving point corresponding to the NPC; If not, determine the positional relationship between the football and the target diagonal based on the current football position; the target diagonal is a diagonal obtained by connecting two diagonal points of two large penalty areas; and determine the target moving point corresponding to the NPC based on the positional relationship and the current football position.
14. The method according to claim 13, characterized in that The step of determining the target moving point corresponding to the NPC according to the position relationship and the current football position includes: If the position relationship is that the football is on the target diagonal line, determine a circle with the current football position as the center and a preset distance as the radius; The designated point on the circle is determined as the target moving point corresponding to the NPC.
15. The method according to claim 13, characterized in that The step of determining the target moving point corresponding to the NPC according to the position relationship and the current football position includes: If the positional relationship is that a perpendicular line between the football and the target diagonal passes through the target diagonal, calculating a vertical distance between the football and the target diagonal; According to the vertical distance, a target moving point corresponding to the NPC is determined on a vertical line segment corresponding to the vertical distance.
16. The method according to claim 15, characterized in that The step of determining, according to the vertical distance, a target moving point corresponding to the NPC on a vertical line segment corresponding to the vertical distance comprises: Reducing the vertical distance according to a preset ratio to obtain a target distance; On the vertical line segment corresponding to the vertical distance, determining a target moving point whose diagonal distance from the target is the target distance; The target moving point corresponding to the NPC is determined according to the target moving point.
17. The method according to claim 16, characterized in that The step of determining the target moving point corresponding to the NPC according to the target moving point comprises: Determining whether the target moving point is within a restricted area; If yes, the intersection of the vertical line segment and the large restricted area is used as the target moving point corresponding to the NPC; If not, the target moving point is used as the target moving point corresponding to the NPC.
18. The method according to claim 13, characterized in that The step of determining the target moving position corresponding to the NPC according to the position relationship and the current football position includes: If the positional relationship is that a perpendicular line between the football and the target diagonal line passes through an extension line of the target diagonal line, determining a perpendicular line segment between the football and the extension line of the target diagonal line; Determine a target vertical line segment that passes through the diagonal point of the large restricted area and is parallel to the vertical line segment; A target moving point corresponding to the NPC is determined on the target vertical line segment.
19. The method according to claim 1, characterized in that The step of determining the target moving position of the NPC in the current control cycle according to the current football position and the identity attribute of the NPC includes: If the identity attribute of the NPC is a sideline referee, determine the intersection point of the vertical line between the second-to-last player and the sideline and the sideline in the half where the NPC is located; The intersection point is determined as the target moving point corresponding to the NPC.
20. The method according to claim 1, characterized in that The step of controlling the NPC to move within the game scene in the current control cycle according to the target moving position corresponding to the NPC includes: If the target moving position includes: a target moving point, controlling the NPC to move to the target moving point in the game scene in the current control cycle; If the target moving position includes: a target moving track, controlling the NPC to move according to the target moving track within the game scene in the current control cycle; If the target moving position includes: a target moving area, the NPC is controlled to move within the target moving area in the game scene in the current control cycle.
21. A device for controlling the movement of a character in a football game, characterized in that: The device comprises: A data acquisition module is used to obtain the current position of the football in the game scene and the identity attributes of each non-player controlled character NPC in the current control cycle; A position determination module is used to determine, for each NPC, a target moving position of the NPC in a current control cycle according to the current football position and the identity attribute of the NPC; the target moving position includes: a target moving point, a target moving track or a target moving area; A movement control module, used to control the movement of the NPC in the game scene in the current control cycle according to the target movement position corresponding to the NPC; The position determination module is further used for: if the identity attribute of the NPC is non-referee and non-goalkeeper, obtaining the current state corresponding to the team to which the NPC belongs and the role position corresponding to the NPC in the previous control cycle; the current state includes an offensive state or a defensive state; determining the target point corresponding to the NPC in the preset court dot matrix according to the identity attribute of the NPC; each point in the preset court dot matrix corresponds to a player with a specified identity attribute in a team formation; each column of points in the preset court dot matrix corresponds to a designated line; the preset court dot matrix corresponds to the back line, the back waist line, the midfield line, the front waist line, the forward line and the center line from left to right; obtaining the target designated line to which the target point belongs in the preset court dot matrix; calculating the coordinate components according to the ball coordinates corresponding to the current football position and the role coordinates corresponding to the role position; determining the coordinate adjustment parameters corresponding to the role coordinates according to the current state, the target designated line, the coordinate components and the ball coordinates; the coordinate adjustment parameters include: a coordinate offset value, a coordinate offset coefficient and a target coordinate value; adjusting the character coordinates based on the coordinate adjustment parameters to obtain the target moving point of the NPC in the current control cycle.
22. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method according to any one of claims 1 to 19.
23. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the method according to any one of claims 1 to 19.
Citation Information
Patent Citations
Control method, control device and control equipment for non-player character and storage medium
CN109731332A
Game information, information storage medium and game device
JP2004321599A