A method and system for spawning npcs in a virtual reality game
Patent Information
- Application Number
- CN202211336673.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-28
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2042-10-28
AI Technical Summary
UE4引擎支持蓝图以及C++,学习成本更高
[0023]第四方面,本发明实施例还提供了一种计算机可读存储介质,其上存储有应用程序,应用程序被处理器执行时实现上述任一实施例方法的步骤。
Smart Images

Figure CN115878085B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of virtual engine technology, and in particular to a method, system, computer device, and storage medium for deploying NPCs in virtual reality games. Background Technology
[0002] Unreal Engine 4 (UE4) is an open-source, cross-platform game development engine. It is suitable for heavyweight game development, with a focus on PC games and high-end mobile games. UE4 supports Blueprints and C++, which has a higher learning curve. In today's world, Unreal Engine is incredibly powerful and has been demonstrated to varying degrees in different fields. How to successfully deploy various NPCs in UE4 virtual reality games is a problem that current UE4 game development needs to solve. Summary of the Invention
[0003] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method, system, computer device and storage medium for placing NPCs in virtual reality games, which can realize the requirement of map-based NPC placement function in virtual reality games using the UE4 virtual engine.
[0004] To address at least one of the aforementioned technical problems, in a first aspect, embodiments of the present invention provide a method for deploying NPCs in a virtual reality game, the method comprising:
[0005] Build the deployment interface in the UE4 blueprint to obtain the virtual reality scene model;
[0006] Draw a spline and generate the corresponding NPC at the starting point of the spline so that the NPC moves with the coordinates of the spline;
[0007] The location of the NPC in the scene is periodically returned to the delivery interface;
[0008] After receiving the data, the deployment interface converts the 3D coordinates of the NPC's location in the scene into 2D coordinates to deploy the NPC.
[0009] The construction of the deployment interface in the UE4 blueprint includes: the deployment interface can be constructed in the UE4 blueprint using UI components.
[0010] Optionally, different NPCs can be deployed based on the choices of different users.
[0011] The process of drawing splines includes: drawing the required spline pattern through program code control.
[0012] Optionally, when the required spline pattern is circular, the AddPoint function is used to add spline points to the spline, allowing the spline to rotate and change its angle according to the points. The code is executed 9 times to add 9 points to the spline. Then, the radius of the circle is determined by the starting point of the spline and the position of the center of the circle, thereby drawing a circular spline.
[0013] The step of periodically returning the location of the NPC in the scene to the delivery interface includes: returning the location of the NPC in the scene to the delivery interface every 0.1 seconds.
[0014] The process of converting the 3D coordinates of the NPC's location in the scene to 2D coordinates includes:
[0015] Get the pixel size (X, Y) of the NPC icon;
[0016] Measure the length and width of the virtual reality scene, and divide the pixel size of the NPC icon by 2;
[0017] Subtract the actual coordinates of the NPC's location from the scene length, and then multiply by the 2D map's aspect ratio on the screen to convert the 3D coordinates of the NPC's location into 2D coordinates.
[0018] In a second aspect, the present invention provides a system for deploying NPCs in a virtual reality game. The method for deploying NPCs in a virtual reality game as described in the first aspect is applied to a system for deploying NPCs in a virtual reality game. The system for deploying NPCs in a virtual reality game includes a construction module, a drawing module, and a deployment module, wherein the deployment module, the drawing module, and the construction module are connected in sequence.
[0019] The construction module is used to build the deployment interface in the UE4 blueprint to obtain a virtual reality scene model;
[0020] The drawing module is used to draw splines and generate corresponding NPCs at the starting points of the splines so that the NPCs move with the coordinates of the splines.
[0021] The deployment module is used to periodically return the location of the NPC in the scene to the deployment interface; after receiving the data, the deployment interface converts the 3D coordinates of the NPC in the scene into 2D coordinates to deploy the NPC.
[0022] Thirdly, embodiments of the present invention also provide a computer device, which includes: a memory, a processor, and an application program stored in the memory and executable on the processor, wherein the processor executes the application program to implement the steps of any of the methods described above.
[0023] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having an application stored thereon, which, when executed by a processor, implements the steps of any of the methods described above.
[0024] The present invention discloses a method and system for deploying NPCs in a virtual reality game. First, a deployment interface is constructed in a UE4 blueprint to obtain a virtual reality scene model. Then, splines are drawn, and corresponding NPCs are generated at the starting points of the splines so that the NPCs move with the coordinates of the splines. Finally, the position of the NPC in the scene is periodically returned to the deployment interface. After receiving the data, the deployment interface converts the 3D coordinates of the NPC in the scene into 2D coordinates to realize the deployment and display of the NPC, thereby meeting the requirements of virtual reality game settings. Attached Figure Description
[0025] Figure 1 This is a flowchart illustrating a method for deploying NPCs in a virtual reality game according to an embodiment of the present invention;
[0026] Figure 2 This is a schematic diagram of constructing a deployment interface in a UE4 blueprint according to an embodiment of the present invention;
[0027] Figure 3 This is a schematic diagram of three parts of a delivery interface in an embodiment of the present invention;
[0028] Figure 4 This is a schematic diagram illustrating the effect of deploying NPCs in an embodiment of the present invention;
[0029] Figure 5 This is a schematic diagram of the structure of a system for deploying NPCs in a virtual reality game according to an embodiment of the present invention;
[0030] Figure 6 This is a schematic diagram of the structural composition of a computer device in an embodiment of the present invention. Detailed Implementation
[0031] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0032] This invention provides a method for deploying NPCs in a virtual reality game, such as... Figure 1 As shown, the method includes the following steps:
[0033] S102, Build the deployment interface in the UE4 blueprint to obtain the virtual reality scene model;
[0034] You can use UI components to build a deployment interface in a UE4 blueprint, and you can also deploy different NPCs based on different users' choices. A specific deployment interface can be built as follows: Figure 2 As shown.
[0035] NPC is a gaming term, short for non-player character. It refers to a type of character in a game that is not controlled by a real player.
[0036] In one embodiment, such as Figure 3 As shown, the deployment interface can be divided into three parts: the deployment bar on the left, the overhead map in the middle, and the deployment bar on the right.
[0037] The deployment bar on the left can be used to deploy different NPCs, such as helicopters, fighter jets, and reconnaissance aircraft, according to the user's selection. After deployment, the corresponding NPC deployment bar will enter a cooldown period.
[0038] The overhead map in the middle displays the NPCs deployed by the user as icons, and allows the user to select a spline path (as shown in the middle of the map) for the NPCs to fly along. The deployment panel on the right displays the NPCs the user is currently deploying and allows for setting limits on the number of NPCs.
[0039] S104, Draw a spline and generate the corresponding NPC at the starting point of the spline so that the NPC moves with the coordinates of the spline;
[0040] Specifically, the required spline pattern can be drawn through program code. When the required spline pattern is circular, the AddPoint function is used to add spline points to the spline, allowing the spline to rotate and change angles according to the points. The code is executed 9 times to add 9 points to the spline (because each point adds 36° upwards, so 9 points can form 360°, which is exactly a circle). Then, the radius of the circle is determined by the starting point of the spline and the position of the center of the circle, thus drawing a circular spline.
[0041] S106, periodically return the location of the NPC in the scene to the delivery interface; specifically, you can choose to return the location of the NPC in the scene to the delivery interface every 0.1 seconds.
[0042] S108: After receiving the data, the deployment interface converts the 3D coordinates of the NPC in the scene into 2D coordinates to deploy the NPC.
[0043] This includes converting the 3D coordinates of the NPC's location in the scene to 2D coordinates, including:
[0044] Get the pixel size (X, Y) of the NPC icon;
[0045] Measure the length and width of the virtual reality scene, and divide the pixel size of the NPC icon by 2;
[0046] Subtract the actual coordinates of the NPC's location from the scene length, and then multiply by the 2D map's aspect ratio on the screen to convert the 3D coordinates of the NPC's location into 2D coordinates.
[0047] After completing the above steps, you can achieve the following: Figure 4 The interface shown is the effect of deploying NPCs.
[0048] In one embodiment, please refer to Figure 5 The present invention also provides a system for placing NPCs in a virtual reality game. The method for placing NPCs in a virtual reality game is applied to a system for placing NPCs in a virtual reality game. The system for placing NPCs in a virtual reality game includes a construction module 302, a drawing module 304, and a placement module 306. The placement module 302, the drawing module 304, and the construction module 306 are connected in sequence.
[0049] The construction module 302 is used to construct the deployment interface in the UE4 blueprint to obtain a virtual reality scene model;
[0050] The drawing module 304 is used to draw splines and generate corresponding NPCs at the starting points of the splines so that the NPCs move with the coordinates of the splines.
[0051] The deployment module 306 is used to periodically return the location of the NPC in the scene to the deployment interface; after receiving the data, the deployment interface converts the 3D coordinates of the NPC in the scene into 2D coordinates to realize the deployment of the NPC.
[0052] For specific limitations regarding a system for deploying NPCs in a virtual reality game, please refer to the limitations regarding a method for deploying NPCs in a virtual reality game described above, which will not be repeated here. The various modules in the aforementioned system for deploying NPCs in a virtual reality game can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0053] This invention provides a computer-readable storage medium storing an application program. When executed by a processor, the program implements a method for deploying NPCs in a virtual reality game, as described in any of the above embodiments. The computer-readable storage medium includes, but is not limited to, any type of disk (including floppy disks, hard disks, optical disks, CD-ROMs, and magneto-optical disks), ROM (Read-Only Memory), RAM (Random Access Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory, magnetic cards, or optical cards. In other words, the storage device includes any medium that can store or transmit information in a readable form by a device (e.g., a computer, a mobile phone), and can be a read-only memory, a disk, or an optical disk, etc.
[0054] This invention also provides a computer application running on a computer, which is used to execute a method for deploying NPCs in a virtual reality game according to any of the above embodiments.
[0055] also, Figure 6 This is a schematic diagram of the structural composition of a computer device in an embodiment of the present invention.
[0056] This invention also provides a computer device, such as... Figure 6 As shown. The computer device includes a processor 602, a memory 603, an input unit 604, and a display unit 605, among other components. Those skilled in the art will understand that... Figure 3 The illustrated device structure is not intended to limit all devices and may include more or fewer components than shown, or combine certain components. Memory 603 can be used to store application program 601 and various functional modules. Processor 602 runs application program 601 stored in memory 603, thereby performing various functional applications and data processing of the device. Memory can be internal memory or external memory, or both. Internal memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), flash memory, or random access memory. External memory may include hard disks, floppy disks, ZIP disks, USB flash drives, magnetic tapes, etc. The memory disclosed in this invention includes, but is not limited to, these types of memory. The memory disclosed in this invention is only an example and not a limitation.
[0057] Input unit 604 is used to receive signal input and user-input keywords. Input unit 604 may include a touch panel and other input devices. The touch panel can collect user touch operations on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel) and drive the corresponding connection device according to a pre-set program; other input devices may include, but are not limited to, one or more of physical keyboards, function keys (such as play control buttons, power buttons, etc.), trackballs, mice, joysticks, etc. Display unit 605 can be used to display user-input information or information provided to the user, as well as various menus of the terminal device. Display unit 605 may be in the form of a liquid crystal display, organic light-emitting diode, etc. Processor 602 is the control center of the terminal device, connecting various parts of the entire device through various interfaces and lines, performing various functions and processing data by running or executing software programs and / or modules stored in memory 603, and calling data stored in memory.
[0058] As one embodiment, the computer device includes: one or more processors 602, memory 603, and one or more applications 601, wherein the one or more applications 601 are stored in memory 603 and configured to be executed by the one or more processors 602, and the one or more applications 601 are configured to perform a method for deploying NPCs in a virtual reality game according to any of the above embodiments.
[0059] Furthermore, the above description provides a detailed explanation of the method, apparatus, computer equipment, and storage medium for deploying NPCs in a virtual reality game, as provided by the embodiments of the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for deploying NPCs in a virtual reality game, characterized in that, The method includes: Build the deployment interface in the UE4 blueprint to obtain the virtual reality scene model; Draw a spline and generate the corresponding NPC at the starting point of the spline so that the NPC moves with the coordinates of the spline; The location of the NPC in the scene is periodically returned to the delivery interface; After receiving the data, the deployment interface converts the 3D coordinates of the NPC in the scene into 2D coordinates to deploy the NPC. The process of converting the 3D coordinates of the NPC's location in the scene to 2D coordinates includes: Get the pixel size (X, Y) of the NPC icon; Measure the length and width of the virtual reality scene, and divide the pixel size of the NPC icon by 2; Subtract the actual coordinates of the NPC's location from the scene length, and then multiply by the 2D map's aspect ratio on the screen to convert the 3D coordinates of the NPC's location into 2D coordinates. The construction of the deployment interface in the UE4 blueprint includes: using UI components to construct the deployment interface in the UE4 blueprint.
2. The method for deploying NPCs according to claim 1, characterized in that, Different NPCs are deployed based on the different user's choices.
3. The method for deploying NPCs according to claim 1, characterized in that, The process of drawing splines includes: drawing the required spline pattern through program code control.
4. The method for deploying NPCs according to claim 3, characterized in that, When the required spline pattern is circular, the AddPoint function is used to add spline points to the spline, allowing the spline to rotate and change its angle based on the points. This code is executed 9 times to add 9 points to the spline. Then, the radius of the circle is determined by the starting point of the spline and the position of the center of the circle, thus drawing a circular spline.
5. The method for deploying NPCs according to claim 1, characterized in that, The step of periodically returning the location of the NPC in the scene to the delivery interface includes: returning the location of the NPC in the scene to the delivery interface every 0.1 seconds.
6. A system for deploying NPCs in a virtual reality game, wherein the method for deploying NPCs in a virtual reality game as described in any one of claims 1 to 5 is applied to a system for deploying NPCs in a virtual reality game, characterized in that, The system for deploying NPCs in a virtual reality game includes a construction module, a drawing module, and a deployment module, wherein the deployment module, the drawing module, and the construction module are connected in sequence. The construction module is used to build the deployment interface in the UE4 blueprint to obtain a virtual reality scene model; The drawing module is used to draw splines and generate corresponding NPCs at the starting points of the splines so that the NPCs move with the coordinates of the splines. The deployment module is used to periodically return the location of the NPC in the scene to the deployment interface; after receiving the data, the deployment interface converts the 3D coordinates of the NPC in the scene into 2D coordinates to realize the deployment of the NPC. The process of converting the 3D coordinates of the NPC's location in the scene to 2D coordinates includes: Get the pixel size (X, Y) of the NPC icon; Measure the length and width of the virtual reality scene, and divide the pixel size of the NPC icon by 2; Subtract the actual coordinates of the NPC's location from the scene length, and then multiply by the 2D map's aspect ratio on the screen to convert the 3D coordinates of the NPC's location into 2D coordinates. The construction of the deployment interface in the UE4 blueprint includes: using UI components to construct the deployment interface in the UE4 blueprint.
7. A computer device comprising a memory, a processor, and an application program stored in the memory and executable on the processor, characterized in that, When the processor executes the application, it implements the steps of the method according to any one of claims 1 to 5.
8. A computer-readable storage medium having an application program stored thereon, characterized in that, When the application is executed by the processor, it implements the steps of the method according to any one of claims 1 to 5.