Roaming method, system and device based on unreal engine and medium
By utilizing the obstacle detection and avoidance algorithm in the Unreal Engine Blueprint Editor, the problem of being unable to avoid obstacles during Unreal Engine roaming was solved, achieving automatic obstacle avoidance and multi-path roaming effects.
Patent Information
- Application Number
- CN202411051133.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-11-26
AI Technical Summary
In existing technologies, Unreal Engine's scene path roaming method cannot perceive and avoid obstacles, resulting in clipping issues.
The LineTraceByChannel node function in the Unreal Engine Blueprint Editor is used to detect obstacles, obtain collision position and attribute information, and adjust the position and direction of the roaming character through the SetActorTransform node to select the shortest avoidance distance to bypass obstacles, thus achieving automatic obstacle avoidance.
It enables obstacle perception and avoidance during roaming, avoids clipping, and can switch between multi-path roaming in a 3D scene and return to the planned route.
Smart Images

Figure CN119027620A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of virtual reality technology, and in particular to a roaming method, system, device and medium based on an Unreal Engine. Background Art
[0002] In Unreal Engine, scene path roaming usually refers to creating a predefined movement path for a character or object in a 3D environment.
[0003] In the prior art, the scene path roaming mode of Unreal Engine is basically single-path fixed roaming, or selecting a path from multiple paths for roaming.
[0004] However, the above technology is unable to sense and avoid obstacles during roaming, resulting in the phenomenon of penetration. Summary of the invention
[0005] The embodiments of the present invention provide a roaming method, system, device and medium based on Unreal Engine, which can solve the problem in the prior art that obstacles cannot be perceived and avoided when facing obstacles during roaming.
[0006] The embodiment of the present invention provides a roaming method based on Unreal Engine, comprising the following steps: using an Unreal Engine blueprint editor to control a roaming character to move on a planned roaming route, and obtaining a roaming position and a roaming direction of the roaming character; using a LineTraceByChannel node function of the Unreal Engine blueprint editor to emit a detection ray for detecting an obstacle from the roaming position along the roaming direction and obtain a detection result, wherein the detection result includes a collision position between the detection ray and the obstacle, and attribute information of the obstacle; controlling the roaming character to roam on the planned roaming route where the obstacle is placed; when the roaming character is at a preset safety distance from the collision position, obtaining an avoidance distance between the collision position and multiple boundaries of the obstacle and selecting the shortest avoidance distance; determining a detour boundary according to the shortest avoidance distance, adjusting the position and direction through a SetActorTransform node of the Unreal Engine blueprint editor, and controlling the roaming character to detour from the determined boundary to avoid the obstacle until returning to the planned roaming route.
[0007] Furthermore, the controlling the roaming character to move on the planned roaming route specifically comprises the following steps: using the spline component Spline of the Unreal Engine Blueprint Editor to plan the roaming route; and using the Timeline node function of the Unreal Engine Blueprint Editor to control the moving position and moving speed of the roaming character on the planned roaming route.
[0008] Furthermore, the controlling of the roaming character also includes creating multiple interfaces for controlling the roaming behavior, specifically including: creating a roaming route management tool blueprint with multiple interfaces through the Unreal Engine Blueprint Editor, and the multiple interfaces include but are not limited to: starting roaming, pausing roaming, stopping roaming and switching roaming routes.
[0009] Furthermore, the obtaining of the roaming position and roaming direction of the roaming character specifically includes: using the GetActorTransform node function of the Unreal Engine Blueprint Editor to obtain the roaming position and roaming direction of the roaming character.
[0010] An embodiment of the present invention provides a roaming device based on Unreal Engine, comprising:
[0011] A roaming information acquisition module is used to control the movement of the roaming character on the planned roaming route using the Unreal Engine Blueprint Editor, and obtain the roaming position and roaming direction of the roaming character; an obstacle detection module is used to use the LineTraceByChannel node function of the Unreal Engine Blueprint Editor to emit a detection ray for detecting obstacles from the roaming position along the roaming direction and obtain the detection result, wherein the detection result includes the collision position between the detection ray and the obstacle, and the attribute information of the obstacle; a roaming avoidance module is used to control the roaming character to roam on the planned roaming route where obstacles are placed; when the roaming character is at a preset safety distance from the collision position, the avoidance distance between the collision position and multiple boundaries of the obstacle is obtained and the shortest avoidance distance is selected; the detour boundary is determined according to the shortest avoidance distance, the position and direction are adjusted through the SetActorTransform node of the Unreal Engine Blueprint Editor, and the roaming character is controlled to detour from the determined boundary to avoid the obstacle until it returns to the planned roaming route.
[0012] An embodiment of the present invention provides a computer device, comprising: a memory and a processor; the memory stores a computer program, and the processor implements the above-mentioned Unreal Engine-based roaming method when executing the computer program.
[0013] An embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the Unreal Engine-based roaming method described above is implemented.
[0014] The embodiments of the present invention provide a roaming method, system, device and medium based on Unreal Engine. Compared with the prior art, the beneficial effects thereof are as follows:
[0015] Use detection rays to detect obstacles and obtain detection results. The detection results include the collision position between the detection rays and the obstacle, as well as the attribute information of the obstacle. Use the collision position in the detection result to sense whether an obstacle has been hit. When roaming to a preset safe distance from the collision position, obtain the avoidance distances between the collision position and multiple boundaries of the obstacle and select the shortest avoidance distance. Determine the detour boundary based on the shortest avoidance distance and detour to avoid the obstacle. After the avoidance is completed, return to the planned roaming route. Finally, the effect of switching the path to avoid the obstacle when the obstacle is sensed is achieved, and then switching back to continue roaming along the planned path. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 A schematic diagram of roaming route planning provided by an embodiment of the present invention;
[0017] Figure 2 A schematic diagram of automatic obstacle avoidance provided by an embodiment of the present invention;
[0018] Figure 3 A flowchart of a roaming method based on Unreal Engine provided by an embodiment of the present invention;
[0019] Figure 4 A schematic diagram of roaming effects provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0020] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention, so the present invention is not limited by the specific embodiments disclosed below.
[0021] See also Figure 1 to Figure 4 The embodiment of the present invention provides a roaming method based on Unreal Engine, comprising the following steps:
[0022] Step 1: Plan the roaming route according to the Spline component of the Unreal Engine Blueprint Editor, and use the Timeline node function to control the moving position and speed of the roaming character on the planned roaming route.
[0023] Step 2: Use the LineTraceByChannel node function of the Unreal Engine Blueprint Editor to emit a detection ray from the roaming position along the roaming direction to detect obstacles and obtain the detection results.
[0024] Specifically, in the blueprint, the GetActorTransform node is used to obtain the current position and direction of the roaming character, a detection ray is sent from the current position, the direction of the detection ray is the current roaming direction, the LineTraceByChannel node is used to emit the detection ray, and the starting position, emission direction and detection distance of the ray are set.
[0025] The detection ray obtains the output result OutHit of the LineTraceByChannel node to determine whether there is an obstacle model within the pre-set obstacle avoidance distance. If there is an obstacle, the location of the current ray collision point and the size and boundary of the obstacle model and other attribute information are obtained.
[0026] Step 3: Control the roaming character to roam on the planned roaming route where obstacles are placed; when the roaming character is at a preset safe distance from the collision position, obtain the avoidance distances between the collision position and multiple boundaries of the obstacle and select the shortest avoidance distance; determine the detour boundary based on the shortest avoidance distance, adjust the position and direction through the SetActorTransform node of the Unreal Engine Blueprint Editor, control the roaming character to maintain a safe distance, and detour from the determined boundary to avoid obstacles until returning to the planned roaming route.
[0027] Specifically, when the automatic roaming reaches a safe distance, the position of the current ray collision point and the direction and distance of the nearest left and right boundaries of the obstacle are determined, and the roaming character is controlled to turn to avoid the obstacle to a safe distance and cross the obstacle, and finally adjust the direction to return to the original planned route.
[0028] The key technologies of the present invention are two points:
[0029] 1. Implement roaming route planning tools and roaming route management tools. The roaming route management tool provides the functions of switching between multiple roaming routes and controlling roaming behavior during roaming.
[0030] 2. Add automatic obstacle avoidance algorithm during roaming, and perform autonomous obstacle avoidance when encountering obstacles during automatic roaming.
[0031] Based on the above, the present invention also has the following beneficial effects:
[0032] Use the roaming route planning tool to draw a route, place the roaming route management tool in the scene, and finally bind the character that needs to roam. By calling the tool interface to control the character's roaming behavior, multi-path roaming and automatic obstacle avoidance in the three-dimensional scene can be realized. The present invention can plan multiple roaming routes at the same time and switch roaming routes in the three-dimensional scene. When encountering obstacles during the roaming process, it can sense and avoid them until returning to the planned roaming route.
[0033] An embodiment of the present invention provides a roaming device based on Unreal Engine, comprising:
[0034] The roaming information acquisition module is used to control the movement of the roaming character on the planned roaming route using the Unreal Engine Blueprint Editor, and obtain the roaming position and roaming direction of the roaming character. The obstacle detection module is used to use the LineTraceByChannel node function of the Unreal Engine Blueprint Editor to emit detection rays for detecting obstacles from the roaming position along the roaming direction and obtain the detection results, which include the collision position between the detection ray and the obstacle, and the attribute information of the obstacle. The roaming avoidance module is used to control the roaming character to roam on the planned roaming route where obstacles are placed; when the roaming character is at a preset safety distance from the collision position, the avoidance distance between the collision position and multiple boundaries of the obstacle is obtained and the shortest avoidance distance is selected; the detour boundary is determined according to the shortest avoidance distance, and the position and direction are adjusted through the SetActorTransform node of the Unreal Engine Blueprint Editor, and the roaming character is controlled to detour from the determined boundary to avoid the obstacle until it returns to the planned roaming route.
[0035] An embodiment of the present invention provides a computer device, comprising: a memory and a processor; the memory stores a computer program, and the processor implements the steps of a roaming method based on an Unreal Engine when executing the computer program.
[0036] An embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of a roaming method based on an Unreal Engine are implemented.
[0037] A specific embodiment is as follows:
[0038] Create a multi-path automatic obstacle avoidance roaming tool based on Unreal Engine:
[0039] Step 1: Create a roaming route planning tool.
[0040] Use the UE Blueprint Editor to create a roaming route planning tool blueprint, and implement roaming route planning through the Spline component.
[0041] Step 2: Create a roaming route management tool.
[0042] Create a roaming route management tool blueprint through the UE blueprint editor, create variables such as RouteName (name), Speed (moving speed), and interfaces such as StartRoam (start roaming), PauseRoam (pause roaming), StopRoam (stop roaming), and ChangeRoamRoute (switch roaming route) to control roaming behavior. Use the Timeline node to control the position and speed of the roaming character moving along the Spline component, and control basic functions such as starting roaming, pausing roaming, stopping roaming, route switching, and speed adjustment by calling the interface.
[0043] Step 3: Create an automatic obstacle avoidance algorithm.
[0044] In the blueprint, use the GetActorTransform node to get the current position and direction of the roaming character, send a detection ray from the current position, the direction of the detection ray is the current roaming direction, use the LineTraceByChannel node to emit the detection ray, and set the starting position, emission direction and detection distance of the ray.
[0045] 2. Detect the ray by obtaining the output result OutHit of the LineTraceByChannel node to determine whether there is an obstacle model within the pre-set obstacle avoidance distance. If there is an obstacle, obtain the location of the current ray collision point and the size and boundary of the obstacle model and other attribute information.
[0046] 3. When the robot automatically roams to a safe distance, it determines the position of the current ray collision point and the shortest avoidance distance and boundary direction of the obstacle, and controls the robot to turn to avoid the obstacle to a safe distance, and finally adjusts the direction to return to the original planned route.
[0047] Step 4: Instructions for using the multi-path automatic obstacle avoidance roaming tool based on Unreal Engine.
[0048] 1. Create or open an existing 3D scene.
[0049] 2. Add roaming route management tools in the 3D scene.
[0050] 3. Add and use the roaming route planning tool to plan the roaming route and bind the roaming route attributes (route name, roaming speed, etc.) to the roaming route management tool.
[0051] 4. Call the interface in the roaming route management tool through the UE blueprint to control the start, pause, stop roaming, switch roaming routes and other behaviors. If obstacles are encountered during roaming, they will automatically avoid them according to the algorithm.
[0052] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be based on the attached claims.
Claims
1. A roaming method based on Unreal Engine, It is characterized in that The following steps are involved: Use the Unreal Engine Blueprint Editor to control the roaming character to move along the planned roaming route, and obtain the roaming position and roaming direction of the roaming character; Use the LineTraceByChannel node function of the Unreal Engine Blueprint Editor to emit a detection ray for detecting obstacles from the roaming position along the roaming direction and obtain a detection result, wherein the detection result includes a collision position between the detection ray and the obstacle, and attribute information of the obstacle; Control the roaming character to roam on the planned roaming route where obstacles are placed; when the roaming character is at a preset safe distance from the collision position, obtain the avoidance distances between the collision position and multiple boundaries of the obstacle and select the shortest avoidance distance; determine the detour boundary based on the shortest avoidance distance, adjust the position and direction through the SetActorTransform node of the Unreal Engine Blueprint Editor, and control the roaming character to detour from the determined boundary to avoid the obstacle until it returns to the planned roaming route.
2. A roaming method based on Unreal Engine as claimed in claim 1, It is characterized in that The controlling the roaming character to move on the planned roaming route specifically comprises the following steps: Use the Spline component of the Unreal Engine Blueprint Editor to plan the roaming route; Use the Timeline node function of the Unreal Engine Blueprint Editor to control the movement position and speed of the wandering character on the planned wandering route.
3. A roaming method based on Unreal Engine as claimed in claim 1, It is characterized in that The controlling roaming role also includes creating multiple interfaces for controlling roaming behavior, specifically including: A roaming route management tool blueprint is created through the Unreal Engine Blueprint Editor, which has multiple interfaces, including but not limited to: start roaming, pause roaming, stop roaming, and switch roaming routes.
4. A roaming method based on Unreal Engine as claimed in claim 1, It is characterized in that The obtaining of the roaming position and roaming direction of the roaming character specifically includes: obtaining the roaming position and roaming direction of the roaming character using the GetActorTransform node function of the Unreal Engine Blueprint Editor.
5. A roaming device based on Unreal Engine, It is characterized in that include: The roaming information acquisition module is used to control the roaming character to move along the planned roaming route using the Unreal Engine Blueprint Editor, and obtain the roaming position and roaming direction of the roaming character; An obstacle detection module, used to use the LineTraceByChannel node function of the Unreal Engine Blueprint Editor to emit a detection ray for detecting obstacles from the roaming position along the roaming direction and obtain a detection result, wherein the detection result includes a collision position between the detection ray and the obstacle, and attribute information of the obstacle; The roaming avoidance module is used to control the roaming character to roam on the planned roaming route where obstacles are placed; when the roaming character is at a preset safe distance from the collision position, the avoidance distance between the collision position and multiple boundaries of the obstacle is obtained and the shortest avoidance distance is selected; the detour boundary is determined according to the shortest avoidance distance, and the position and direction are adjusted through the SetActorTransform node of the Unreal Engine Blueprint Editor to control the roaming character to detour from the determined boundary to avoid the obstacle until it returns to the planned roaming route.
6. A computer device, include: Memory and processor; The memory stores a computer program, wherein the processor implements a roaming method based on Unreal Engine according to any one of claims 1 to 4 when executing the computer program.
7. A computer-readable storage medium storing a computer program, It is characterized in that When the computer program is executed by a processor, a roaming method based on Unreal Engine as claimed in any one of claims 1 to 4 is implemented.
