Control Method, Device, Electronic Device and Storage Medium for Virtual Characters in Games

By obtaining the air wall blocking direction vector and the character velocity vector, calculating the target speed vector and controlling the character movement, the problem of inflexible and unruly air wall blocking in the prior art is solved, and a more stable game character boundary control is achieved.

CN115138073BActive Publication Date: 2025-07-29NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210745346.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-27
Publication Date
2025-07-29
Estimated Expiration
2042-06-27

AI Technical Summary

Technical Problem

In the prior art, the air wall implementation solution based on physical rigid bodies and area detection triggers is not flexible and robust enough in the game, resulting in the phenomenon that the player character is easily stuck in the air wall or penetrates the wall.

Method used

By obtaining the barrier direction vector of the air wall and the current speed vector of the virtual character, calculate the target speed vector, and control the role movement at a specific time, combined with the time interval for prohibiting collision processing, the flexibility and robustness of the barrier effect are improved.

Benefits of technology

It effectively reduces the probability of player characters passing through walls, ensures the stable movement of characters within the boundary of air walls, and improves the flexibility and reliability of air wall blocking.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115138073B_ABST
    Figure CN115138073B_ABST
Patent Text Reader

Abstract

The present application provides a method, apparatus, electronic device, and storage medium for controlling a virtual character in a game. A graphical user interface is displayed through a terminal device. The graphical user interface includes at least a part of a virtual scene, a controlled virtual character located in the virtual scene, and an air wall disposed around an effective activity area of the controlled virtual character in the virtual scene; the air wall is a physical trigger; a blocking direction vector perpendicular to the plane where the air wall is located and pointing to the effective activity area is correspondingly set for the air wall; the method includes: in response to the controlled virtual character entering or leaving the air wall, obtaining the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character, thereby determining the target velocity vector of the controlled virtual character and performing movement control on the controlled virtual character. The present application can make the processing after collision have a certain degree of flexibility and improve the robustness of the air wall blocking effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of game technologies, and particularly to a method, device, electronic device, and storage medium for controlling virtual characters in a game. Background Art

[0002] In game development, restricting the activity range of players is a relatively common requirement, and the boundary of such a restricted area is usually referred to as an "air wall". When the character controlled by the player (hereinafter referred to as the "player") touches the air wall, the speed and position attributes of the player need to be controlled so that the player does not leave the pre-set activity range.

[0003] Currently, there are the following two ways to implement blocking through the air wall:

[0004] A) Using a rigid body of the physical system to implement the air wall effect. Each air wall is equivalent to a cuboid with physical collision detection function. With the collision detection function of the physical system in common game engines currently, a cuboid rigid body is attached to this air wall and its mass is specified. With the simulation of the rigid body movement by the physical system in the game engine, the speed of other rigid bodies colliding with the air wall during game operation will change, thus conveniently implementing the blocking effect.

[0005] B) Using a region detection trigger and combining it with script control to implement the air wall effect. Each air wall is equivalent to a cuboid trigger with region detection function. Taking the trigger of the physical system in common game engines currently as an example, during game operation, when the rigid body volume of the player coincides with the volume of this air wall trigger, the game engine will consider that a collision has been detected currently. According to the result of the collision detection, by calling the callback functions pre-registered in the script at different times, the speed of the player can be reversed, thus implementing the blocking of the player.

[0006] The above two technical solutions have the following defects respectively:

[0007] A) The air wall implementation solution based on physical rigid bodies: The collision detection and post-collision processing of this solution completely rely on the physical system of the game engine, with insufficient customizable space and lack of flexibility.

[0008] B) The air wall implementation solution based on region detection triggers and scripts: Although this solution separates the collision detection and post-collision processing and uses scripts to control the post-collision performance, it is still not robust enough and cannot achieve good blocking. Summary of the Invention

[0009] The purpose of the present application is to provide a method, device, electronic device, and storage medium for controlling virtual characters in a game. When detecting the target time when the controlled virtual character enters or leaves the air wall, blocking is performed according to the unique blocking direction vector of the air wall and the current velocity vector of the character, which can make the processing after collision have a certain degree of flexibility and improve the robustness of the air wall blocking effect.

[0010] In a first aspect, an embodiment of the present application provides a method for controlling a virtual character in a game. A graphical user interface is displayed through a terminal device. The graphical user interface includes at least part of a virtual scene, a controlled virtual character located in the virtual scene, and an air wall is provided around the effective activity area of the controlled virtual character in the virtual scene; the air wall is a physical trigger; the air wall is correspondingly provided with a blocking direction vector perpendicular to the plane where the air wall is located and pointing to the effective activity area; the method includes: in response to the controlled virtual character entering or leaving the air wall, obtaining the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; determining the target velocity vector of the controlled virtual character according to the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; controlling the movement of the controlled virtual character according to the target velocity vector.

[0011] In a preferred embodiment of the present application, the step of determining the target velocity vector of the controlled virtual character according to the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character includes: calculating the dot product of the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; if the dot product is negative, reversing the velocity direction corresponding to the current velocity vector to obtain the target velocity vector of the controlled virtual character; if the dot product is non-negative, using the current velocity vector as the target velocity vector.

[0012] In a preferred embodiment of the present application, before the step of obtaining the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character, it further includes: determining whether the target time when the controlled virtual character enters or leaves the air wall is within the prohibited collision processing time interval; the prohibited collision processing time interval is determined by the previous detected target time that is not within the prohibited collision processing time interval and a preset time period; if not, continue to execute the step of obtaining the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; if so, lock the current velocity of the controlled virtual character.

[0013] In a preferred embodiment of the present application, the step of responding to the controlled virtual character entering or leaving the air wall includes: performing a collision detection on the controlled virtual character and the air wall to obtain a first detection result of the current collision detection; obtaining a second detection result of the previous collision detection, and determining whether the controlled virtual character currently enters or leaves the air wall according to the first detection result and the second detection result.

[0014] In a preferred embodiment of the present application, the step of performing a collision detection on the controlled virtual character and the air wall to obtain a first detection result of the current collision detection includes: detecting whether at least partial coincidence occurs between the rigid body of the controlled virtual character and the rigid body of the air wall, and if so, determining that the first detection result of the current collision detection is a collision.

[0015] In a preferred embodiment of the present application, the step of determining that the controlled virtual character currently enters or leaves the air wall according to the first detection result and the second detection result includes: if the first detection result is a collision and the second detection result is no collision, determining that the controlled virtual character enters the air wall; if the first detection result is no collision and the second detection result is a collision, determining that the controlled virtual character leaves the air wall.

[0016] In a preferred embodiment of the present application, the above method further includes: if the target time for the controlled virtual character to enter or leave the air wall is not within the prohibited collision processing time interval, updating the prohibited collision processing time interval according to the target time and a preset time period.

[0017] In a preferred embodiment of the present application, the step of controlling the movement of the controlled virtual character according to the target velocity vector includes: controlling the controlled virtual character to move at a speed magnitude and a speed direction determined by the target velocity vector.

[0018] In a second aspect, an embodiment of the present application further provides a control device for a virtual character in a game. A graphical user interface is displayed through a terminal device. The graphical user interface includes at least a partial virtual scene, a controlled virtual character located in the virtual scene, and an air wall arranged around an effective activity area of the controlled virtual character in the virtual scene; the air wall is a physical trigger; a blocking direction vector perpendicular to the plane where the air wall is located and pointing to the effective activity area is correspondingly set for the air wall; the device includes: a vector acquisition module, configured to acquire the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character in response to the controlled virtual character entering or leaving the air wall; a vector determination module, configured to determine a target velocity vector of the controlled virtual character according to the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; and a movement control module, configured to control the movement of the controlled virtual character according to the target velocity vector.

[0019] In a third aspect, an embodiment of the present application further provides an electronic device, including a processor and a memory. 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.

[0020] Fourthly, an embodiment of the present application further provides a computer-readable storage medium storing computer-executable instructions, which, when called and executed by a processor, cause the processor to implement the method described in the first aspect above.

[0021] A method, apparatus, electronic device and storage medium for controlling a virtual character in a game provided by an embodiment of the present application display a graphical user interface through a terminal device. The graphical user interface includes at least a part of a virtual scene, a controlled virtual character located in the virtual scene, and an air wall arranged around an effective activity area of the controlled virtual character in the virtual scene. The air wall is a physical trigger. A blocking direction vector perpendicular to the plane where the air wall is located and pointing to the effective activity area is correspondingly set for the air wall. In this embodiment, when it is detected that the controlled virtual character enters or leaves the air wall, the unique blocking direction vector of the air wall and the current speed vector of the controlled virtual character are obtained. According to the blocking direction vector of the air wall and the current speed vector of the controlled virtual character, the target speed vector of the controlled virtual character is determined. The controlled virtual character is controlled to move according to the target speed vector. In this embodiment, for both the two moments when the character enters or leaves the air wall, blocking is performed according to the unique blocking direction vector of the air wall and the current speed vector of the character, which can make the post-collision processing have a certain degree of flexibility and improve the robustness of the air wall blocking effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0023] Figure 1 It is a schematic diagram of a blocking direction vector of an air wall provided by an embodiment of the present application;

[0024] Figure 2 It is a flowchart of a method for controlling a virtual character in a game provided by an embodiment of the present application;

[0025] Figure 3 It is a flowchart of another method for controlling a virtual character in a game provided by an embodiment of the present application;

[0026] Figure 4 It is a structural block diagram of a device for controlling a virtual character in a game provided by an embodiment of the present application;

[0027] Figure 5Schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0028] The technical solutions 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, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts belong to the scope of protection of the present application.

[0029] In the two current solutions for implementing blocking through air walls, the following problems exist respectively:

[0030] 1) In the air wall implementation solution based on physical rigid bodies, collision detection and post-collision processing completely rely on the physical system of the game engine, with insufficient customizable space and lack of flexibility.

[0031] 2) In the air wall implementation solution based on area detection triggers and scripts, the blocking direction of the air wall is not specified. Therefore, if both entering and leaving the air wall are regarded as the timing for reversing the speed, it is possible for the player to get stuck inside the air wall cuboid and unable to get out. Therefore, the common current practice is to only reverse the speed when entering the air wall. Although collision detection and post-collision processing are separated, and scripts are used to control the post-collision performance, it is still not robust enough and cannot achieve good blocking.

[0032] For example, when we set the speed to reverse when the player enters the trigger, at the intersection of multiple air walls, there is a certain probability that the player will reverse the speed multiple times, resulting in passing through the air wall and being unable to return to the effective activity area.

[0033] Based on this, the embodiments of the present application provide a method, device, electronic device and storage medium for controlling a virtual character in a game. When detecting the target timing of the controlled virtual character entering or leaving the air wall, blocking is performed according to the unique blocking direction vector of the air wall and the current speed vector of the character, which can make the post-collision processing have a certain degree of flexibility and improve the robustness of the air wall blocking effect. For the convenience of understanding this embodiment, first, a method for controlling a virtual character in a game disclosed in the embodiments of the present application will be introduced in detail.

[0034] The embodiments of the present application provide a method for controlling a virtual character in a game. In this method, a graphical user interface is displayed through a terminal device. The graphical user interface includes at least part of the virtual scene, a controlled virtual character located in the virtual scene, and air walls are arranged around the effective activity area of the controlled virtual character in the virtual scene; the air walls are physical triggers; a blocking direction vector perpendicular to the plane where the air wall is located and pointing to the effective activity area is correspondingly set for the air wall; seeFigure 1 Top view of the air wall shown. The air wall is a plane formed by extending a line segment W0W1 on the XoZ plane of the world coordinates along the +Y and -Y directions of the world coordinates. Usually, in order to access the physical system of the game engine and reduce the probability of passing through the wall, a thickness is added to the air wall and it is embodied as a cuboid. In the figure, N is the blocking direction vector of the air wall, which is perpendicular to the plane where the air wall is located and points to the effective activity area of the controlled virtual character.

[0035] See Figure 2 Flowchart of the control method for the virtual character in the game shown. The above method specifically includes the following steps:

[0036] Step S202, in response to the controlled virtual character entering or leaving the air wall, obtain the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character.

[0037] Collision detection is a periodic detection carried out at regular time intervals. Based on the results of two adjacent collision detections, it can be determined whether the controlled virtual character enters or leaves the air wall. Since the above air wall is a cuboid trigger with a thickness, when the rigid body of the controlled virtual character coincides with the rigid body of the air wall (including partial coincidence or full coincidence), the result of the collision detection can be determined as a collision. When the result of two adjacent collision detections changes from no collision to a collision, it is determined that the controlled virtual character enters the air wall. When the result of two adjacent collision detections changes from a collision to no collision, it is determined that the controlled virtual character leaves the air wall.

[0038] For the two situations determined by the above collision detection results, the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character are both obtained to further determine the target velocity vector of the controlled virtual character, that is, whether to block the controlled virtual character.

[0039] Step S204, determine the target velocity vector of the controlled virtual character according to the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character.

[0040] In the case of obtaining the above two vectors, the dot product can be calculated based on the above two vectors. In the case where the dot product is negative, the velocity is reversed to obtain the target velocity vector.

[0041] Step S206, control the movement of the controlled virtual character according to the target velocity vector.

[0042] During specific implementation, control the controlled virtual character to move at the speed magnitude and speed direction determined by the target velocity vector.

[0043] In the method for controlling a virtual character in a game provided by an embodiment of the present application, a graphical user interface is displayed through a terminal device. The graphical user interface includes at least a partial virtual scene, a controlled virtual character located in the virtual scene, and an air wall arranged around the effective activity area of the controlled virtual character in the virtual scene; the air wall is a physical trigger; a blocking direction vector perpendicular to the plane where the air wall is located and pointing to the effective activity area is correspondingly set for the air wall; in this embodiment, when it is detected that the controlled virtual character enters or leaves the air wall, the unique blocking direction vector of the air wall and the current velocity vector of the controlled virtual character are obtained; according to the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character, the target velocity vector of the controlled virtual character is determined; the controlled virtual character is controlled to move according to the target velocity vector. In this embodiment, for the two target timings of the character entering or leaving the air wall, blocking is performed according to the blocking direction vector of the air wall and the current velocity vector of the character, which can make the post-collision processing have a certain degree of flexibility and improve the robustness of the air wall blocking effect.

[0044] An embodiment of the present application further provides a method for controlling a virtual character in a game. This embodiment focuses on explaining the generation process of the above interval, the determination method of the target velocity vector, and the preferred collision detection method.

[0045] In order to further improve the robustness of the blocking effect, a prohibited collision processing time interval is also set in an embodiment of the present application. By comparing the time when the target timing is detected with this interval, it is determined whether to perform subsequent processing, that is, whether this collision is effective.

[0046] The specific movement control process is as follows. See Figure 3 as shown:

[0047] Step S302, in response to the controlled virtual character entering or leaving the air wall, record the target time when the controlled virtual character enters or leaves the air wall.

[0048] The specific process of detecting that the controlled virtual character enters or leaves the air wall is as follows:

[0049] (1) Perform a collision detection on the controlled virtual character and the air wall to obtain the first detection result of the current collision detection.

[0050] Detect whether at least partial coincidence occurs between the rigid body of the controlled virtual character and the rigid body of the air wall. If so, determine that the first detection result of the current collision detection is a collision; if not, determine that the first detection result of the current collision detection is no collision.

[0051] (2) Obtain the second detection result of the previous collision detection, and determine whether the controlled virtual character currently enters or leaves the air wall based on the first detection result and the second detection result.

[0052] If the first detection result is a collision and the second detection result is no collision, determine that the controlled virtual character enters the air wall; if the first detection result is no collision and the second detection result is a collision, determine that the controlled virtual character leaves the air wall.

[0053] Whether it is detected that the controlled virtual character enters the air wall or leaves the air wall, record its target time.

[0054] Step S304, determine whether the target time when the controlled virtual character enters or leaves the air wall is within the prohibited collision handling time interval.

[0055] The above-mentioned prohibited collision handling time interval is determined by the target time detected last time that was not within the prohibited collision handling time interval and a preset time period; for example, if the target time detected last time that was not within the prohibited collision handling time interval is 1:10:30, then add a preset time period such as 10 seconds on this basis to determine that the prohibited collision handling time interval is 1:10:30 - 1:10:40. If the detected target time is 1:10:50, which has exceeded the above time interval, continue to execute the step of obtaining the blocking direction vector of the air wall and the current speed vector of the controlled virtual character; if the detected target time is 1:10:35, lock the current speed of the controlled virtual character, that is, the player cannot control the change of the character's speed.

[0056] That is, when it is detected that the target time when the controlled virtual character enters or leaves the air wall is not within the prohibited collision handling time interval, execute step S306 to obtain the blocking direction vector of the air wall and the current speed vector of the controlled virtual character; when it is detected that the target time is within the prohibited collision handling time interval, execute step S308 to lock the current speed of the controlled virtual character.

[0057] After the above step S306, execute step S310. According to the blocking direction vector of the air wall and the current speed vector of the controlled virtual character, determine the target speed vector of the controlled virtual character, and control the movement of the controlled virtual character according to the target speed vector.

[0058] The specific process of determining the target speed vector is as follows:

[0059] Calculate the dot product of the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; if the dot product is negative, reverse the velocity direction corresponding to the current velocity vector to obtain the target velocity vector of the controlled virtual character; if the dot product is non - negative, use the current velocity vector as the target velocity vector.

[0060] As Figure 1 shown, when the controlled virtual character P collides with the air wall W0W1, a preset normal direction N of this air wall is its blocking direction vector. At this time, calculate the dot product of the current velocity vector V of the controlled virtual character and the blocking direction vector N:

[0061] d = dot(V, N)

[0062] When d < 0, it is considered that the current velocity direction of the controlled virtual character is opposite to the blocking direction. Therefore, perform a reverse operation on the current velocity vector of the controlled virtual character:

[0063] V = -V;

[0064] Use the updated V as the target velocity vector and control the movement of the controlled virtual character according to the target velocity vector.

[0065] By the above method, reverse the speed of the controlled virtual character when it leaves the air wall, which can further improve the robustness of the air wall blocking effect.

[0066] Step S312: Update the prohibited collision processing time interval according to the target time and the preset time period.

[0067] Specifically, the above - mentioned target time can be used as the first time, and the second time is determined according to the first time and the preset time period; use the time interval determined by the first time and the second time to update the prohibited collision processing time interval. This step S312 occurs when the target time when the controlled virtual character enters or leaves the air wall is not within the prohibited collision processing time interval, and can be executed simultaneously with steps S306 and S310.

[0068] For example, the first time T s when the collision is detected is used as the starting point. After T f time, use the first time as T s as the starting point and the second time T s + T f as the end point to update the above - mentioned prohibited collision processing time interval with the interval [T s , T s + T f .

[0069] This solution further improves robustness by restricting collision handling to once within a period of time and disabling the player's control over the character's speed during this restricted period.

[0070] To further improve the blocking effect of this embodiment, in a preferred embodiment of this application, the above method further includes: setting a function to lock the current speed of the controlled virtual character within the updated prohibited collision handling time interval. That is, within the above time interval, the player has no control over the controlled virtual character, and the controlled virtual character only moves at the current speed magnitude and in the current speed direction without change. Within the above time interval, collision handling between the controlled virtual character and the air wall is prohibited, and at the same time, the player's movement input is locked until the game time exceeds, and then it returns to normal.

[0071] The following is a specific example. When the controlled virtual character collides with air wall A at the junction of two air walls A and B, the speed is reversed and the controlled virtual character is pushed out of the cuboid area of air wall A, but the controlled virtual character enters the cuboid area of air wall B. And due to the restriction of the prohibited collision time, the controlled virtual character will not collide with air wall B. At this time, the controlled virtual character is inside the cuboid area of air wall B. When the controlled virtual character tries to move outside the effective activity area again, the speed reversal timing when leaving the air wall comes into play, that is, when detecting the timing of the controlled virtual character leaving the air wall, reversing the speed again will make the controlled virtual character return to the effective activity area.

[0072] In addition, for a controlled virtual character moving at high speed, the phenomenon of passing through the wall still occurs. After passing through the wall, if the player controls the character to move into the effective activity area, at this time, the dot product of the blocking direction of the air wall and the speed orientation of the character is greater than or equal to 0, so the speed of the controlled virtual character will not be reversed, and the controlled virtual character will return to the effective activity area without any hindrance.

[0073] In the method for controlling a virtual character in a game provided by an embodiment of this application, the flexibility of the air wall solution based on triggers and scripts is retained, and the robustness of blocking is improved. Among them:

[0074] 1) The timing of reversing the speed twice when the controlled virtual character enters and leaves the air wall trigger is provided, reducing the probability of the player passing through the wall.

[0075] 2) A prohibited collision handling time interval is provided to avoid the situation where the speed of the controlled virtual character is reversed multiple times and finally passes through the wall after continuous collisions with multiple air walls. At the same time, locking the player's movement input within the prohibited collision handling time interval also reduces the probability of the player passing through the wall.

[0076] 3) Reverse the player's speed selectively according to the blocking direction of the air wall, effectively avoiding the problem of the wrong speed direction of the player after colliding with the air wall. At the same time, it also allows the player to return to the effective activity area after passing through the wall, which further improves the robustness of this application.

[0077] Based on the above method embodiments, the embodiments of this application also provide a control device for virtual characters in a game. A graphical user interface is displayed through a terminal device. The graphical user interface includes at least part of the virtual scene, the controlled virtual character located in the virtual scene, and an air wall is arranged around the effective activity area of the controlled virtual character in the virtual scene; the air wall is a physical trigger; an only blocking direction vector perpendicular to the plane where the air wall is located and pointing to the effective activity area is correspondingly set for the air wall; see Figure 4 As shown, the device includes:

[0078] A vector acquisition module 42, configured to respond to the controlled virtual character entering or leaving the air wall, and acquire the blocking direction vector of the air wall and the current speed vector of the controlled virtual character; a vector determination module 44, configured to determine the target speed vector of the controlled virtual character according to the blocking direction vector of the air wall and the current speed vector of the controlled virtual character; a movement control module 46, configured to control the movement of the controlled virtual character according to the target speed vector.

[0079] In the control device for virtual characters in the game provided by the embodiments of this application, when it is detected that the controlled virtual character enters or leaves the air wall, the only blocking direction vector of the air wall and the current speed vector of the controlled virtual character are acquired; according to the blocking direction vector of the air wall and the current speed vector of the controlled virtual character, the target speed vector of the controlled virtual character is determined; the movement of the controlled virtual character is controlled according to the target speed vector. In this embodiment, for the two opportunities of the character entering or leaving the air wall, blocking is performed according to the only blocking direction vector of the air wall and the current speed vector of the character, which can make the post-collision processing have a certain degree of flexibility and improve the robustness of the air wall blocking effect.

[0080] The above vector determination module is further configured to calculate the dot product of the blocking direction vector of the air wall and the current speed vector of the controlled virtual character; if the dot product is negative, reverse the speed direction corresponding to the current speed vector to obtain the target speed vector of the controlled virtual character; if the dot product is non-negative, use the current speed vector as the target speed vector.

[0081] The above device further includes: a time judgment module, configured to judge whether the target time for the controlled virtual character to enter or leave the air wall is within the prohibited collision handling time interval before the steps of obtaining the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; the prohibited collision handling time interval is determined by the target time detected last time that was not within the prohibited collision handling time interval and a preset time period; if not, continue to execute the steps of obtaining the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; if so, lock the current velocity of the controlled virtual character.

[0082] The above device further includes: a collision detection module, configured to perform a collision detection on the controlled virtual character and the air wall to obtain a first detection result of the current collision detection; obtain a second detection result of the previous collision detection, and determine whether the controlled virtual character currently enters or leaves the air wall according to the first detection result and the second detection result.

[0083] In a preferred embodiment of the present application, the above collision detection module is configured to detect whether at least partial coincidence occurs between the rigid body of the controlled virtual character and the rigid body of the air wall, and if so, determine that the first detection result of the current collision detection is a collision.

[0084] In a preferred embodiment of the present application, the above collision detection module is configured to, if the first detection result is a collision and the second detection result is no collision, determine that the controlled virtual character enters the air wall; if the first detection result is no collision and the second detection result is a collision, determine that the controlled virtual character leaves the air wall.

[0085] In a preferred embodiment of the present application, the above device further includes: an interval update module, configured to update the prohibited collision handling time interval according to the target time and a preset time period if the target time for the controlled virtual character to enter or leave the air wall is not within the prohibited collision handling time interval.

[0086] The above movement control module is further configured to control the controlled virtual character to move at the speed magnitude and speed direction determined by the target velocity vector.

[0087] The device provided in the embodiment of the present application has the same implementation principle and the same technical effects as those in the foregoing method embodiment. For a brief description, for the parts not mentioned in the embodiment of the device, reference may be made to the corresponding content in the foregoing method embodiment.

[0088] The embodiment of the present application further provides an electronic device, such as Figure 5As shown, it is a schematic structural diagram of the electronic device. Among them, the electronic device includes a processor 51 and a memory 50. The memory 50 stores computer-executable instructions that can be executed by the processor 51. The processor 51 executes the computer-executable instructions to implement the following method.

[0089] The processor is used to: in response to the controlled virtual character entering or leaving the air wall, obtain the blocking direction vector of the air wall and the current speed vector of the controlled virtual character; determine the target speed vector of the controlled virtual character according to the blocking direction vector of the air wall and the current speed vector of the controlled virtual character; control the movement of the controlled virtual character according to the target speed vector.

[0090] The processor is used to: calculate the dot product of the blocking direction vector of the air wall and the current speed vector of the controlled virtual character; if the dot product is negative, reverse the speed direction corresponding to the current speed vector to obtain the target speed vector of the controlled virtual character; if the dot product is non-negative, use the current speed vector as the target speed vector.

[0091] The processor is used to: determine whether the target time for the controlled virtual character to enter or leave the air wall is within the prohibited collision handling time interval; the prohibited collision handling time interval is determined by the target time detected last time that was not within the prohibited collision handling time interval and a preset time period; if not, continue to execute the step of obtaining the blocking direction vector of the air wall and the current speed vector of the controlled virtual character; if so, lock the current speed of the controlled virtual character.

[0092] The processor is used to: perform a collision detection on the controlled virtual character and the air wall to obtain the first detection result of the current collision detection; obtain the second detection result of the previous collision detection, and determine whether the controlled virtual character currently enters or leaves the air wall according to the first detection result and the second detection result.

[0093] The processor is used to: detect whether at least part of the rigid body of the controlled virtual character coincides with the rigid body of the air wall. If so, determine that the first detection result of the current collision detection is a collision.

[0094] The processor is used to: if the first detection result is a collision and the second detection result is no collision, determine that the controlled virtual character enters the air wall; if the first detection result is no collision and the second detection result is a collision, determine that the controlled virtual character leaves the air wall.

[0095] The processor is used to: if the target time for the controlled virtual character to enter or leave the air wall is not within the prohibited collision handling time interval, update the prohibited collision handling time interval according to the target time and the preset time period.

[0096] The processor is configured to: control the controlled virtual character to move at a speed magnitude and in a speed direction determined by the target speed vector.

[0097] In the embodiment of the present application, when the electronic device detects a target timing at which the controlled virtual character enters or leaves an air wall, it acquires the unique blocking direction vector of the air wall and the current speed vector of the controlled virtual character; determines the target speed vector of the controlled virtual character according to the blocking direction vector of the air wall and the current speed vector of the controlled virtual character; and controls the movement of the controlled virtual character according to the target speed vector. In this embodiment, for both the timing when the character enters the air wall and the timing when the character leaves the air wall, blocking is performed based on the unique blocking direction vector of the air wall and the current speed vector of the character, which can make the processing after the collision have a certain degree of flexibility and improve the robustness of the air wall blocking effect.

[0098] In Figure 5 In the illustrated embodiment, the electronic device further includes a bus 52 and a communication interface 53, where the processor 51, the communication interface 53, and the memory 50 are connected through the bus 52.

[0099] The memory 50 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is implemented through at least one communication interface 53 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 52 may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, etc. The bus 52 may be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, Figure 5 only a single bidirectional arrow is used in

[0100] The processor 51 may be an integrated circuit chip with the ability to process signals. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in the processor 51 or the instructions in the form of software. The above-mentioned processor 51 may be a general-purpose processor, including a central processing unit (CPU for short), a network processor (NP for short), etc.; it may also be a digital signal processor (DSP for short), an application specific integrated circuit (ASIC for short), a field-programmable gate array (FPGA for short), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly implemented by the hardware decoding processor, or implemented by a combination of the hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the art 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. This storage medium is located in the memory, and the processor 51 reads the information in the memory and combines its hardware to complete the steps of the method in the foregoing embodiments.

[0101] The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by the processor, the computer-executable instructions cause the processor to implement the following method:

[0102] The processor is configured to: in response to the controlled virtual character entering or leaving the air wall, obtain the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; determine the target velocity vector of the controlled virtual character according to the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; control the movement of the controlled virtual character according to the target velocity vector.

[0103] The processor is configured to: calculate the dot product of the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; if the dot product is negative, reverse the velocity direction corresponding to the current velocity vector to obtain the target velocity vector of the controlled virtual character; if the dot product is non-negative, use the current velocity vector as the target velocity vector.

[0104] The processor is configured to: determine whether the target time for the controlled virtual character to enter or leave the air wall is within the prohibited collision handling time interval; the prohibited collision handling time interval is determined by the target time detected last time that was not within the prohibited collision handling time interval and a preset time period; if not, continue to execute the step of obtaining the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; if so, lock the current velocity of the controlled virtual character.

[0105] The processor is configured to: perform a collision detection on the controlled virtual character and the air wall to obtain a first detection result of the current collision detection; obtain a second detection result of the previous collision detection, and determine whether the controlled virtual character currently enters or leaves the air wall according to the first detection result and the second detection result.

[0106] The processor is configured to: detect whether at least partial overlap occurs between the rigid body of the controlled virtual character and the rigid body of the air wall, and if so, determine that the first detection result of the current collision detection is a collision.

[0107] The processor is configured to: if the first detection result is a collision and the second detection result is no collision, determine that the controlled virtual character enters the air wall; if the first detection result is no collision and the second detection result is a collision, determine that the controlled virtual character leaves the air wall.

[0108] The processor is configured to: if the target time for the controlled virtual character to enter or leave the air wall is not within the prohibited collision handling time interval, update the prohibited collision handling time interval according to the target time and the preset time period.

[0109] The processor is configured to: control the controlled virtual character to move at the speed magnitude and speed direction determined by the target velocity vector.

[0110] When the electronic device provided by the embodiment of the present application detects the target timing for the controlled virtual character to enter or leave the air wall, it obtains the unique blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; determines the target velocity vector of the controlled virtual character according to the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; and controls the movement of the controlled virtual character according to the target velocity vector. For both the timing when the character enters the air wall and the timing when the character leaves the air wall, this embodiment performs blocking according to the unique blocking direction vector of the air wall and the current velocity vector of the character, which can make the post-collision processing have a certain degree of flexibility and improve the robustness of the air wall blocking effect.

[0111] The computer program product of the method, apparatus, and electronic device provided by the embodiments of the present application includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the method described in the foregoing method embodiments. For specific implementation, reference can be made to the method embodiments, which will not be elaborated herein.

[0112] 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.

[0113] If the above-mentioned functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium executable by a processor. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program code.

[0114] In the description of the present application, it should be noted that the orientation or positional relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings. It is 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 should not be construed as a limitation to the present application. In addition, the terms "first", "second", and "third" are only used for descriptive purposes and should not be construed as indicating or implying relative importance.

[0115] Finally, it should be noted that the above-described embodiments are only specific implementation manners of the present application, which are used to illustrate the technical solutions of the present application, rather than limiting it. The protection scope of the present application is not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the technical field familiar with the present application can still modify the technical solutions described in the foregoing embodiments, or can easily think of changes, or perform equivalent replacements on some of the technical features; 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 all be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method for controlling a virtual character in a game, characterized in that, Displaying a graphical user interface through a terminal device, where the graphical user interface includes at least a partial virtual scene, a controlled virtual character located in the virtual scene, and an air wall disposed around an effective activity area of the controlled virtual character in the virtual scene; the air wall is a physical trigger; a blocking direction vector perpendicular to a plane where the air wall is located and pointing to the effective activity area is correspondingly set for the air wall; the method includes: In response to the controlled virtual character entering or leaving the air wall, obtaining the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; Determining a target velocity vector of the controlled virtual character according to the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; Controlling the movement of the controlled virtual character according to the target velocity vector; Wherein, the step of determining the target velocity vector of the controlled virtual character according to the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character includes: Calculating a dot product of the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; If the dot product is negative, reversing the velocity direction corresponding to the current velocity vector to obtain the target velocity vector of the controlled virtual character; If the dot product is non - negative, taking the current velocity vector as the target velocity vector.

2. The method according to claim 1, characterized in that, Before the step of obtaining the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character, it further includes: Judging whether a target time when the controlled virtual character enters or leaves the air wall is within a prohibited collision handling time interval; the prohibited collision handling time interval is determined by a previous detected target time not within the prohibited collision handling time interval and a preset time period; If not, continuing to execute the step of obtaining the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; If so, locking the current velocity of the controlled virtual character.

3. The method according to claim 1, wherein The step of responding to the controlled virtual character entering or leaving the air wall includes: Performing a collision detection on the controlled virtual character and the air wall to obtain a first detection result of the current collision detection; Obtaining a second detection result of the previous collision detection, and determining that the controlled virtual character currently enters or leaves the air wall according to the first detection result and the second detection result.

4. The method according to claim 3, characterized in that The step of performing a collision detection on the controlled virtual character and the air wall to obtain a first detection result of the current collision detection includes: Detecting whether at least partial coincidence occurs between a rigid body of the controlled virtual character and a rigid body of the air wall, and if so, determining that the first detection result of the current collision detection is a collision.

5. The method according to claim 3, characterized in that, The step of determining that the controlled virtual character currently enters or leaves the air wall according to the first detection result and the second detection result includes: If the first detection result is a collision and the second detection result is no collision, determining that the controlled virtual character enters the air wall; If the first detection result indicates no collision and the second detection result indicates a collision, it is determined that the controlled virtual character leaves the air wall.

6. The method according to claim 2, characterized in that, The method further includes: If the target time for the controlled virtual character to enter or leave the air wall is not within the prohibited collision handling time interval, the prohibited collision handling time interval is updated according to the target time and the preset time period.

7. The method according to claim 1, characterized in that The step of controlling the movement of the controlled virtual character according to the target velocity vector includes: Controlling the controlled virtual character to move at the speed magnitude and speed direction determined by the target velocity vector.

8. A control device for virtual characters in a game, characterized in that, A graphical user interface is displayed through a terminal device. The graphical user interface includes at least part of a virtual scene, a controlled virtual character located in the virtual scene, and an air wall provided around the effective activity area of the controlled virtual character in the virtual scene; the air wall is a physical trigger; a blocking direction vector perpendicular to the plane where the air wall is located and pointing to the effective activity area is correspondingly set for the air wall; the device includes: A vector acquisition module, configured to respond to the controlled virtual character entering or leaving the air wall, and acquire the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; A vector determination module, configured to determine the target velocity vector of the controlled virtual character according to the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; A movement control module, configured to control the movement of the controlled virtual character according to the target velocity vector; Wherein, the vector determination module is configured to: Calculate the dot product of the blocking direction vector of the air wall and the current velocity vector of the controlled virtual character; If the dot product is negative, reverse the velocity direction corresponding to the current velocity vector to obtain the target velocity vector of the controlled virtual character; If the dot product is non - negative, use the current velocity vector as the target velocity vector.

9. An electronic device, characterized in that, It includes a processor and a memory. 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 7.

10. A computer-readable storage medium, characterized in that, The computer - readable storage medium stores computer - executable instructions. When the computer - executable instructions are called and executed by a processor, the computer - executable instructions cause the processor to implement the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Virtual lens control method and device, storage medium and electronic equipment

    CN107704165A

  • Method and system for delimiting map area boundary in game map and computer readable storage medium

    CN112396698A