A method and a terminal for realizing a pseudo 3D scene based on Unity3D using 2D facets
By using 2D patch models and orthographic camera technology in Unity3D, combined with the Navmesh automatic pathfinding plugin, the problem of high rendering computational cost in 3D games is solved, achieving efficient pseudo-3D scene effects.
Patent Information
- Application Number
- CN202211431589.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2042-11-15
AI Technical Summary
The use of 3D models to draw maps in existing 3D games results in high rendering computation costs and high memory usage.
The system replaces the 3D model with a 2D patch model, replaces the perspective camera with an orthographic camera, and sets a fixed viewing angle. Combined with the Navmesh automatic pathfinding plugin and region mesh baking technology, it controls the movement and turning of the character in the 3D scene.
It reduces the game package size and rendering computation, achieving realistic 3D visual effects while reducing game performance consumption.
Smart Images

Figure CN116271824B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of Unity3D, and particularly relates to a method for realizing pseudo 3D scenes by using 2D patches based on Unity3D and a terminal. BACKGROUND
[0002] In a 3D game, a 3D map is often drawn to realize the movement of a character in a scene and the interaction with a prop. However, a map is usually directly created by using a terrain, 3D modeling, etc., and then baked by using a Navmesh to realize the movement and interaction of the character in the scene. A 3D model is generally composed of multiple surfaces, and the number of surfaces of the 3D model is large. If the 3D model is directly used to draw a 3D map, the rendering calculation consumption is large, which causes certain consumption in game performance and also causes the memory of the entire 3D map to be large. SUMMARY
[0003] (I) Technical problem to be solved
[0004] In order to solve the above problems in the prior art, the present application provides a method for realizing pseudo 3D scenes by using 2D patches based on Unity3D and a terminal, which can effectively reduce the package size of a scene and reduce the rendering calculation amount.
[0005] (II) Technical scheme
[0006] In order to achieve the above purpose, a technical scheme adopted by the present application is as follows: a method for realizing pseudo 3D scenes by using 2D patches based on Unity3D, comprising:
[0007] S1. In a 3D scene in which a 2D patch model is pre-made and placed, a perspective camera is replaced by an orthogonal camera, and the camera position and viewing angle of the orthogonal camera are set.
[0008] S2. A region mesh for a character to walk is received, which is made based on the 3D scene, and the region mesh is placed in the 3D scene according to user operation. The region mesh is baked by using a Navmesh automatic pathfinding plug-in, and the region mesh includes a first region mesh of a plane and a second region mesh with a height difference.
[0009] S3. A NavmeshAgent component is added to the character, and the movement and turning of the character in each direction are controlled by obtaining the position of the region mesh clicked by the user and the coordinate offset and rotation offset of the character.
[0010] The application discloses a terminal for realizing a pseudo 3D scene based on a 2D sheet and using Unity3D.
[0011] S1, in a 3D scene in which a 2D sheet model is pre-prepared and placed, a default perspective camera is replaced by an orthogonal camera, and a camera position and an observation angle of the orthogonal camera are set;
[0012] S2, a region grid for a character role to walk in is received based on the 3D scene, the region grid is placed into the 3D scene according to a user operation, and the region grid is baked by using a Navmesh automatic pathfinding plug-in, wherein the region grid comprises a first region grid of a plane and a second region grid with a height difference;
[0013] S3, a NavmeshAgent component is added to the character role, and movement and steering of each direction of the character role are controlled by acquiring a position of the region grid clicked by the user and a coordinate offset and a rotation offset of the character role.
[0014] (Three) beneficial effects
[0015] The application has the beneficial effects that the 2D sheet model is used to replace the prior art 3D model, the 3D picture effect of the character role moving in the 3D scene is realized, the overall package size is reduced, and the rendering calculation amount and the game performance consumption are reduced. The default perspective camera is replaced by the orthogonal camera, and the fixed observation angle of the orthogonal camera is set, so that the 2D sheet model is avoided from being exposed, and the 3D model effect is visually achieved. The first region grid of the plane and the second region grid with the height difference are set in the region grid for the character role to walk in, so that the functions of the character role horizontally walking and moving up and down are provided, and the picture effect of the character role moving in the 3D model is achieved. BRIEF DESCRIPTION OF DRAWINGS
[0016] Figure 1 A method flow chart for realizing a pseudo 3D scene based on a 2D sheet and using Unity3D is provided.
[0017] Figure 2 A structure schematic diagram of a terminal for realizing a pseudo 3D scene based on a 2D sheet and using Unity3D is provided.
[0018] Figure 3 A schematic diagram of a user placing a prepared 2D sheet model into a prepared 3D scene based on a demand in embodiment one is provided.
[0019] Figure 4 Figure 1 is a schematic diagram of a 3D scene in which the orthogonal camera is at a first viewing angle and the area mesh is baked for Embodiment One;
[0020] Figure 5 Figure 2 is a schematic diagram of a 3D scene in which the orthogonal camera is at a second viewing angle and the area mesh is baked for Embodiment One
[0021] Figure 6 Figure 3 is a schematic diagram of the area mesh being placed into the 3D scene according to user operation for Embodiment One;
[0022] Figure 7 Figure 4 is a schematic diagram of a scene in which the character is in the first interactive area of paint ground for Embodiment One;
[0023] Figure 8 Figure 5 is a schematic diagram of a scene in which the character is in the first interactive area of sand ground for Embodiment One;
[0024] Figure 9 Figure 6 is a schematic diagram of a scene in which the character is in the second interactive area of a slide for Embodiment One;
[0025] Figure 10 Figure 7 is a schematic diagram of the overall method for Embodiment One;
[0026]
BRIEF DESCRIPTION OF THE DRAWINGS
[0027] 1. A terminal for implementing a pseudo 3D scene using 2D patches based on Unity3D; 2. a memory; 3. a processor. DETAILED DESCRIPTION
[0028] In order to better explain the present application, in order to facilitate understanding, the present application is described in detail below through a specific embodiment in combination with the accompanying drawings.
[0029] Referring to Figure 1 Figure 1, a method for implementing a pseudo 3D scene using 2D patches based on Unity3D, comprising:
[0030] S1. In a 3D scene in which a 2D patch model is pre-made and placed, a default perspective camera is replaced with an orthogonal camera, and the camera position and viewing angle of the orthogonal camera are set;
[0031] S2. An area mesh for a character to walk in is received based on the 3D scene, the area mesh is placed into the 3D scene according to user operation, the area mesh is baked using a Navmesh automatic pathfinding plug-in, and the area mesh includes a first area mesh of a plane and a second area mesh with a height difference;
[0032] S3, adding a NavmeshAgent component on the character role, controlling the movement and turning of the character role in each direction by obtaining the coordinate offset and rotation offset of the position of the user clicking the area mesh and the coordinate of the character role.
[0033] From the above description, the beneficial effects of the present application are that the 2D patch model is used to replace the prior art 3D model, the 3D picture effect of the character role moving in the 3D scene is realized, the overall package size is reduced, and the rendering calculation amount and game performance consumption are reduced. By using the orthogonal camera to replace the default perspective camera, and setting the fixed viewing angle of the orthogonal camera, the 2D patch model can be avoided, and the effect of the 3D model can be achieved visually. And in the area mesh for the character role to walk, the first area mesh including a plane and the second area mesh with a height difference, so as to provide the function of horizontal walking and up and down movement of the character role, so as to achieve the picture effect of the character role moving in the 3D model.
[0034] Further, the S3 further comprises:
[0035] When the character role moves, the orthogonal camera only moves in the x-axis direction following the movement of the character role.
[0036] From the above description, the orthogonal camera can only move in the x-axis direction following the movement of the character role, so as to ensure that the picture can follow the movement of the character role, while ensuring that the viewing angle does not change, and avoiding the picture from being exposed due to the movement of the character role.
[0037] Further, a collision body for ray detection is placed in the area mesh in advance, and the S3 comprises:
[0038] The NavmeshAgent component is added on the character role, and when the user's mouse completes the clicking action in the scene, the ray detection is performed according to the emission ray of the mouse clicking position, the coordinate of the collision point position and the coordinate offset and rotation offset of the character role are calculated based on the ray detection, the next coordinate position of the character role is obtained according to the coordinate position of the character role and the coordinate offset and rotation offset of the character role, and the movement and turning of the character role are executed.
[0039] Further, the S2 further comprises:
[0040] A first interactive area is configured in the first area mesh, and the first interactive area is used to leave a mark when the character role walks in the first interactive area;
[0041] The second interaction region is configured in the second region grid, and the second interaction region is used for the character role to perform a moving action including an up and down direction along with a height difference of the second interaction region when the character role walks in the second interaction region.
[0042] As can be seen from the above description, the first interaction region can be a sand ground or a painted ground, and the character role can increase the footprint mark in the moving process, and the second interaction region can be a slide, and the character role can perform the operations of climbing and sliding in the moving process, so that the character role presents the real 3D effect in the moving process of the region grid.
[0043] Please refer to Figure 2 The terminal for realizing pseudo 3D scene based on Unity3D by using 2D patch, as shown in the drawing, comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, and the processor realizes the following steps when executing the computer program:
[0044] S1, in the 3D scene in which the 2D patch model is pre-made and has been placed, the default perspective camera is replaced by an orthogonal camera, and the camera position and observation angle of the orthogonal camera are set;
[0045] S2, receiving the region grid for the character role to walk based on the 3D scene, placing the region grid into the 3D scene according to the user operation, and baking the region grid by using the Navmesh automatic pathfinding plug-in, wherein the region grid comprises a first region grid of a plane and a second region grid with a height difference;
[0046] S3, adding the NavmeshAgent component on the character role, and controlling the movement and turning of the character role in each direction by obtaining the position of the region grid clicked by the user and the coordinate offset and rotation offset of the character role.
[0047] As can be seen from the above description, the beneficial effects of the present application are that the 2D patch model is used to replace the prior art 3D model, the 3D picture effect of the character role moving in the 3D scene is realized, the overall package size is reduced, and the rendering calculation amount and game performance consumption are reduced. By replacing the default perspective camera with the orthogonal camera and setting the fixed observation angle of the orthogonal camera, the 2D patch model can be avoided, and the effect of the 3D model can be achieved visually. And in the region grid for the character role to walk, the first region grid of the plane and the second region grid with the height difference are included, so that the functions of the horizontal walking and the up and down movement of the character role are provided, and the picture effect of the character role moving in the 3D model is achieved.
[0048] Further, the S3 further comprises:
[0049] When the character moves, the orthographic camera only moves in the x-axis direction to follow the movement of the character.
[0050] As can be seen from the above description, the orthographic camera can only move in the x-axis direction to follow the movement of the character, thereby ensuring that the picture can follow the movement of the character while ensuring that the viewing angle does not change, thereby avoiding picture failure caused by the movement of the character.
[0051] Further, a collision body for ray detection is pre-placed in the area grid, and the S3 comprises:
[0052] A NavmeshAgent component is added to the character, and when a click action of a user mouse in the scene is detected, a ray is emitted according to the mouse click position, and the coordinates of the collision point position and the coordinate offset and rotation offset of the character are calculated based on the ray detection, the next coordinate position of the character is obtained according to the coordinate position of the character and the coordinate offset and rotation offset of the character, and the movement and turning of the character are performed.
[0053] Further, the S2 further comprises:
[0054] A first interaction area is configured in the first area grid, and the first interaction area is used to leave a mark when the character walks in the first interaction area;
[0055] A second interaction area is configured in the second area grid, and the second interaction area is used to perform a movement action including an up and down direction when the character walks in the second interaction area.
[0056] As can be seen from the above description, the first interaction area can be a sand area, a painted area, etc., and the character will leave a mark of footprints during movement in the first interaction area, and the second interaction area can be a slide, etc., and the character can perform the operations of climbing and sliding during movement in the second interaction area, thereby presenting a real 3D effect of the character during movement in the area grid.
[0057] Embodiment one
[0058] Please refer to Figure 1 , Figures 3 to 10 A method for implementing a pseudo-3D scene based on Unity3D using 2D patches, comprising:
[0059] S1, in the 3D scene in which the 2D patch model is pre-made and placed, the default perspective camera is replaced by an orthogonal camera, and the camera position and viewing angle of the orthogonal camera are set, which can avoid the 2D patch model from being exposed, and visually achieve the effect of a 3D model; refer to Figure 3 Fig. 1 shows a schematic diagram of a user placing a made 2D patch model in a made 3D scene based on a demand; refer to Figure 4 and Figure 5 Fig. 2 shows a schematic diagram of two different viewing angles of the orthogonal camera, it can be seen that, Figure 4 the viewing angle of the orthogonal camera in Fig. 2 has a situation of the 2D patch model being exposed, so the fixed viewing angle of the orthogonal camera needs to be Figure 5 the viewing angle in Fig. 1;
[0060] S2, receiving a region mesh for a character role to walk based on the 3D scene, refer to Figure 6 Fig. 3 shows that the region mesh is placed in the 3D scene according to user operation, refer to Figure 4 and Figure 5 Fig. 4 shows that the region mesh is baked using a Navmesh automatic pathfinding plug-in, the region mesh includes a first region mesh of a plane and a second region mesh with a height difference;
[0061] In the S2, further comprising:
[0062] configuring a first interactive region in the first region mesh, the first interactive region is used for leaving a mark when the character role walks in the first interactive region;
[0063] configuring a second interactive region in the second region mesh, the second interactive region is used for the character role to perform a moving action including up and down directions when the character role walks in the second interactive region. That is, the movable directions of the first interactive region include front, back, left and right directions, and the movable directions of the second interactive region include front, back, left, right, up and down directions.
[0064] For example, refer to Figure 7 and Figure 8 Fig. 5 shows that when the first interactive region is a sand ground or a painted ground, the character role will increase the mark of footprints in the moving process, refer to Figure 9 Fig. 6 shows that the second interactive region can be a slide, and the character role can perform the operations of climbing and sliding in the moving process, so that the character role presents a real 3D effect in the moving process in the region mesh.
[0065] S3, adding a NavmeshAgent component on the character role, controlling the movement and turning of the character role in each direction by obtaining the coordinate offset and rotation offset of the character role from the position of the user clicking the area mesh.
[0066] wherein a collision body for ray detection is pre-placed in the area mesh, and the S3 comprises:
[0067] adding a NavmeshAgent component on the character role, when a user's mouse completes a clicking action in the scene, performing ray detection according to the ray emitted from the mouse clicking position, obtaining the coordinate of the collision point position and the coordinate offset and rotation offset of the character role based on the ray detection, obtaining the next coordinate position of the character role according to the coordinate position of the character role and the coordinate offset and rotation offset of the character role, and performing the movement and turning of the character role.
[0068] wherein the S3 further comprises:
[0069] When the character role moves, the orthographic camera only moves in the x-axis direction following the movement of the character role. When receiving the action of the user switching the view distance, the size value of the orthographic camera is changed.
[0070] Embodiment two
[0071] Please refer to Figure 2 A terminal 1 for implementing a pseudo 3D scene based on Unity3D using 2D patches, comprising a memory 2, a processor 3, and a computer program stored in the memory 2 and executable on the processor 3, wherein the processor 3 implements the steps in embodiment one when executing the computer program.
[0072] The above is only an embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent transformation or direct or indirect application in related technical fields based on the content of the present application specification and drawings is also included in the patent protection scope of the present application.
Claims
1. A method for realizing a pseudo-3D scene using 2D patches based on Unity3D, characterized in that, include: S1. In a 3D scene where 2D patch models have been pre-made and placed, replace the default perspective camera with an orthographic camera, and set the camera position and viewing angle of the orthographic camera. S2. Receive the area mesh for character movement based on the 3D scene, place the area mesh into the 3D scene according to user operation, and bake the area mesh using the Navmesh automatic pathfinding plugin. The area mesh includes a first area mesh in a plane and a second area mesh with a height difference. S3. Add a NavmeshAgent component to the character and control the movement and turning of the character in various directions by obtaining the position of the user clicking the grid in the area and the coordinate offset and rotation offset of the character. Following S3, the following also includes: When the character moves, the orthogonal camera follows the character's movement by moving only in the x-axis direction; If a collider for ray detection is pre-placed in the area grid, then S3 includes: A NavmeshAgent component is added to the character. When a user's mouse click is detected in the scene, ray detection is performed based on the emitted ray from the mouse click location. Based on the ray detection, the coordinates of the collision point and the character's coordinate offset and rotation offset are calculated. Based on the character's coordinate position and the character's coordinate offset and rotation offset, the next position coordinates and rotation angle of the character are obtained, and the character's movement and turning are executed.
2. The method for realizing a pseudo-3D scene using 2D patches based on Unity3D according to claim 1, characterized in that, S2 also includes: A first interactive area is configured in the first area grid. The first interactive area is used to leave a mark as the character walks in the first interactive area. A second interactive area is configured in the second area grid. When a character walks in the second interactive area, the character will perform movement actions including up and down directions according to the height difference of the second interactive area.
3. A terminal based on Unity3D that utilizes 2D patches to implement a pseudo-3D scene, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it performs the following steps: S1. In a 3D scene where 2D patch models have been pre-made and placed, replace the default perspective camera with an orthographic camera, and set the camera position and viewing angle of the orthographic camera. S2. Receive the area mesh for character movement based on the 3D scene, place the area mesh into the 3D scene according to user operation, and bake the area mesh using the Navmesh automatic pathfinding plugin. The area mesh includes a first area mesh in a plane and a second area mesh with a height difference. S3. Add a NavmeshAgent component to the character and control the movement and turning of the character in various directions by obtaining the position of the user clicking the grid in the area and the coordinate offset and rotation offset of the character. Following S3, the following also includes: When the character moves, the orthogonal camera follows the character's movement by moving only in the x-axis direction; If a collider for ray detection is pre-placed in the area grid, then S3 includes: A NavmeshAgent component is added to the character. When a user's mouse click is detected in the scene, ray detection is performed based on the emitted ray from the mouse click location. Based on the ray detection, the coordinates of the collision point and the character's coordinate offset and rotation offset are calculated. The next coordinate position of the character is obtained based on the character's coordinate position and the character's coordinate offset and rotation offset, and the character's movement and turning are executed.
4. The terminal based on Unity3D using 2D patches to realize a pseudo-3D scene according to claim 3, characterized in that, S2 also includes: A first interactive area is configured in the first area grid. The first interactive area is used to leave a mark as the character walks in the first interactive area. A second interactive area is configured in the second area grid. When a character walks in the second interactive area, the character will perform movement actions including up and down directions according to the height difference of the second interactive area.
Citation Information
Patent Citations
Pseudo-3D forced perspective methods and devices
CN103329547A
Method and system for combining and separating BIM-based model and picture
CN106296575A