Dynamic parameterization traffic flow generation system based on unreal engine
By integrating automated traffic flow generation and vehicle obstacle avoidance modules into Unreal Engine, the problems of low efficiency and lack of realism in traffic flow animation production are solved. This achieves efficient and dynamic traffic flow generation and intelligent vehicle obstacle avoidance, significantly improving the application effect of virtual scenes. It also solves the technical problems of vehicle intelligent interactivity in existing technologies, overcomes the technical challenges of intelligent vehicle obstacle avoidance, and addresses the issues of insufficient dynamic interactivity and realism in existing traffic flow animations, thereby improving the development efficiency and immersion of virtual scenes.
Patent Information
- Application Number
- CN202511212989.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-28
- Publication Date
- 2025-12-16
AI Technical Summary
Existing technologies in Unreal Engine lack dynamic interactivity in traffic animation, cannot respond in real time to temporary obstacles and other traffic participants, have long production cycles and suffer from severe clipping issues, resulting in poor simulation effects and realism.
An automated traffic flow generation module and an automatic vehicle obstacle avoidance module are integrated into Unreal Engine. Lanes and traffic flow are generated in a parametric manner, giving vehicles the ability to autonomously avoid obstacles and dynamically plan paths, and enabling dynamic updates and interactions of vehicle instances.
It improves the efficiency and realism of traffic flow generation, solves the problems of low efficiency and insufficient realism in traditional methods, realizes high-fidelity dynamic interaction and rapid deployment, and enhances the development efficiency and immersion of large-scale virtual scenes.
Smart Images

Figure CN121147360A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer graphics and virtual simulation technology, and in particular to a dynamic parameterized traffic flow generation system based on Unreal Engine. Background Technology
[0002] In the construction of large-scale 3D virtual scenes such as smart cities and digital twins, vehicle flow is a core element for enhancing the vividness and realism of the scene. Currently, the way vehicle flow animation is implemented on platforms such as Unreal Engine has significant technical defects: traditional keyframe animation lacks dynamic interactivity, vehicles cannot react in real time to temporary obstacles or other traffic participants, and the workload for handling complex road networks and a large number of vehicles is enormous, the production cycle is long, the maintainability and scalability are extremely poor, and clipping is prone to occur, resulting in poor simulation effects and realism; generating data through professional traffic simulation software and importing it into Unreal Engine is a cumbersome and time-consuming process, the imported animation is static, and it is impossible to interact and adjust parameters in real time within the engine, thus losing the dynamic advantages of the 3D engine.
[0003] Therefore, the industry urgently needs a solution that can be embedded in mainstream 3D engines, has an efficient production process, adjustable parameters, and intelligent vehicle behavior to meet the production needs of large-scale, high-fidelity dynamic traffic flow in smart city projects and solve the aforementioned technical pain points. Summary of the Invention
[0004] To address the aforementioned technical challenges, this invention provides a dynamic traffic flow generation system for smart city, digital twin, and traffic simulation projects within a game engine (Unreal Engine) environment. This system integrates road generation, traffic flow generation, and intelligent control, all within Unreal Engine. It achieves automated and convenient generation of roads and traffic flow through parameterization, and endows vehicles with autonomous obstacle avoidance and dynamic path planning capabilities. This significantly enhances the realism, credibility, and production efficiency of traffic simulation in digital twin scenarios, meeting the needs of large-scale, high-fidelity, and highly interactive smart city projects.
[0005] The technical solution of this invention is:
[0006] A dynamic parameterized lane traffic flow generation system based on Unreal Engine, comprising:
[0007] The automated traffic flow generation module is used to programmatically generate several lane paths and automatically generate traffic flow on the specified roads by setting variables such as the number of lanes, lane width, vehicle speed, vehicle density, and vehicle model style through variables exposed to the user interface.
[0008] The vehicle automatic obstacle avoidance module is used to generate vehicle instances on the path in a timed and quantitative manner according to the vehicle model, generation density and target speed set by the user; when the vehicle detects an obstacle in front, it actively judges and executes deceleration, braking or attempts to change lanes to the adjacent empty lane.
[0009] Furthermore,
[0010] The automated traffic flow generation module calculates vehicle positions by: obtaining a reference position and rotating it along a spline at a predetermined distance; calculating the lateral offset in the direction of the spline normal or the right vector based on the current lane index and lane width; and combining the reference position with the lateral offset to obtain the final planar coordinates.
[0011] The automated traffic flow generation module also includes a ground alignment unit, which detects the ground below by emitting rays from the vehicle's planar coordinate position and uses the detected collision point height to correct the vehicle's world space height.
[0012] The automated traffic flow generation module updates the vehicle position in each frame: it calculates the new travel distance of the vehicle along the spline based on the preset speed and frame interval, then recalculates the world space transformation of the vehicle based on the new distance, and updates the display of the corresponding vehicle instance in the rendering module by calling the interface function for updating instance transformation.
[0013] Before updating the vehicle's position, the vehicle's automatic obstacle avoidance module emits a ray forward from the vehicle's current position to perform collision detection. If an obstacle is detected, the module will switch driving routes or stop actively depending on the obstacle.
[0014] Furthermore,
[0015] The work steps are as follows:
[0016] Step 1: Instantiate the system in the 3D scene and match it to the road geometry in the scene by editing the splines of its path definition module;
[0017] Step 2: Set traffic flow attributes, including the number of lanes, vehicle speed, and vehicle model, through the user interface of the parameterized configuration module;
[0018] Step 3: The static generation module automatically responds to the configuration in Step 2, generating and previewing the static distribution of vehicles in the editor;
[0019] Step 4: Start the program and let the dynamic control module take over. Calculate and update the dynamic transformation of each vehicle instance along the spline frame by frame to form a continuous traffic flow animation.
[0020] Furthermore,
[0021] In step three, when generating the static vehicle distribution, the lane offset distance Offset is calculated using the following formula: Offset = (LaneIndex - 2NLanes - 1) × WLane, where LaneIndex is the lane index.
[0022] $N_{Lanes}$ represents the total number of lanes, and $W_{Lane}$ represents the lane width.
[0023] In step four, the dynamic control module also executes obstacle avoidance logic, which means that before calculating the new position of the vehicle, it first performs forward ray detection and adjusts the effective driving speed of the current frame based on the detection results.
[0024] The beneficial effects of this invention are
[0025] By combining vehicle instantiation rendering with dynamic interaction logic, this invention effectively addresses the core pain points of traditional traffic flow animation production, namely low efficiency, high performance overhead, and insufficient realism. This method enables rapid deployment, smooth operation, and high-fidelity dynamic interaction of traffic flows, significantly improving the development efficiency and immersiveness of large-scale virtual scenes. This invention provides a highly efficient, easy-to-use, and reusable dynamic environment solution for major projects such as smart cities and digital twins, and is a key technology for enhancing the vividness and realism of large-scale 3D scenes. Attached Figure Description
[0026] Figure 1 This is a schematic diagram of the workflow of the present invention. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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 some embodiments of the present invention, but not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0028] This embodiment provides a dynamic traffic flow generation system built based on the Unreal Engine Blueprint visualization scripting system. This system integrates two main functional modules: automated traffic flow generation and automatic vehicle obstacle avoidance, achieving the effect of efficiently creating realistic traffic flow in a 3D scene. The specific implementation process is as follows:
[0029] Step 1: System initialization and parameter configuration, the specific process is as follows:
[0030] 1. In the Unreal Engine's Content Browser, create a new Blueprint Class, select Actor as its parent class, and name it BP_SplineTraffic.
[0031] 2. Open the BP_SplineTraffic blueprint editor and add a spline component in the component panel. This component will serve as the path definition module for visually drawing traffic flow paths.
[0032] 3. In the "My Blueprints" panel of the blueprint, create a set of variables and set them all to "Instance Editable" to build the parameterized configuration module.
[0033] Step Two: Automated Traffic Flow Generation and Control, the specific process is as follows:
[0034] 1. Clean up old instances: At the beginning of the script, retrieve all instanced static mesh components (ISMs) dynamically generated by this blueprint and call the Clear Instances function for each component. This operation ensures that old vehicle layouts are cleared whenever the user modifies paths or parameters, preventing instance stacking.
[0035] 2. Dynamically create ISM components: Iterate through the VehicleMeshes array defined in step one. For each static mesh model in the array, call the Add Instanced Static Mesh Component function to dynamically create a corresponding ISM component, and store these newly created components in a temporary component array variable, which together constitute the rendering module.
[0036] 3. Generate vehicle instances in a loop: Use an outer loop to traverse all lanes (loop count is...).
[0037] NumberOfLanes), then use an inner loop to arrange vehicles along the spline at the spacing defined by VehicleDensity.
[0038] 4. Calculate the world transformation of a single instance: In the inner loop, accurately calculate the world space transformation for each vehicle to be generated.
[0039] a. Obtain the baseline transformation: Based on the distance along the spline in the current loop, call the Get Transform atDistance Along Spline function to obtain the world position (Location) and rotation (Rotation) of the point.
[0040] b. Calculate lane offset: Based on the current lane index (LaneIndex), total number of lanes (NLanes), and lane width (WLane), calculate the lateral offset perpendicular to the spline tangent. The formula is: Offset = (LaneIndex - 2NLanes - 1) × WLane. Multiply this offset by the right vector of the spline at that point and add it to the reference position to obtain the vehicle's accurate planar position within the lane.
[0041] c. Perform ground alignment: If StickToGround is true, a single-channel ray (Line Trace ByChannel) is emitted from above the vehicle's planar position calculated in the previous step (e.g., Z+1000) to directly below it (e.g., Z-2000). If the ray detects a collision, the Z coordinate of the collision point is taken as the vehicle's final Z coordinate.
[0042] 5. Add instance to ISM: The final calculated complete transformation information, including position, rotation and scaling, is added to the corresponding ISM component through the Add Instance function to complete the static placement of a vehicle instance.
[0043] Step 3: Automatic vehicle avoidance system, the specific process is as follows:
[0044] 1. Implementation of the normal cruise logic: The vehicle obtains the currently assigned road spline and its own distance traveled on that spline. This increment is added to the current distance of the instance stored in the VehicleDistances array to obtain the new travel distance. If the new distance exceeds the total length of the spline, a modulo operation is performed on it to restart from the starting point of the spline, thus achieving cyclical driving.
[0045] 2. A collision sensor is installed at the front of the vehicle blueprint. When this sensor detects overlap with other vehicles or obstacles ahead, it emits a ray along its forward vector to detect the obstacle and determine if it is indeed on the current driving path. If an obstacle is detected, a speed multiplier between 0 and 1 is calculated using linear interpolation or a curve function based on the obstacle's hit distance and a preset maximum detection distance. This multiplier is then multiplied by the base speed to obtain the effective speed for the current frame. If no obstacle is detected, the base speed is used directly.
[0046] 3. Update travel distance: Multiply the effective speed of the current frame by the duration of the frame (Delta Seconds) to obtain the travel increment for the current frame. Add this increment to the current distance of the instance stored in the VehicleDistances array to obtain the new travel distance. If the new distance exceeds the total length of the spline, perform a modulo operation on it to restart from the spline's starting point, thus achieving cyclic travel.
[0047] 4. Calculate and apply the new transformation: Using the updated travel distance, repeat sub-steps 2 and 3 in step 3 to calculate the new world space transformation for this instance in this frame.
[0048] 5. Path Replanning Task: In the obstacle avoidance sequence, a volume tracking signal is emitted for the target areas of the vehicle's left and right adjacent lanes to detect whether the adjacent lanes are available. If an adjacent lane is detected to be free of obstacles within a safe distance, the moving target point is immediately updated to that free lane, thus driving the vehicle to perform a smooth lane change. If, after detection, neither the left nor right lanes meet the lane change conditions, active braking logic is executed, smoothly reducing the vehicle speed until it stops, maintaining a safe distance from obstacles ahead, and continuing to detect until the road ahead is clear or a new lane change opportunity appears.
[0049] The above description is merely a preferred embodiment of the present invention and is used only to illustrate the technical solution of the present invention, and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. A dynamic parameterized lane traffic flow generation system based on Unreal Engine, characterized in that, include: The automated traffic flow generation module is used to programmatically generate several lane paths and automatically generate traffic flow on the specified roads by setting variables such as the number of lanes, lane width, vehicle speed, vehicle density, and vehicle model style through variables exposed to the user interface. The vehicle automatic obstacle avoidance module is used to generate vehicle instances on the path in a timed and quantitative manner according to the vehicle model, generation density and target speed set by the user; when the vehicle detects an obstacle in front, it actively judges and executes deceleration, braking or attempts to change lanes to the adjacent empty lane.
2. The system according to claim 1, characterized in that, The automated traffic flow generation module calculates vehicle positions by: obtaining a reference position and rotating it along a spline at a predetermined distance; calculating the lateral offset in the direction of the spline normal or the right vector based on the current lane index and lane width; and combining the reference position with the lateral offset to obtain the final planar coordinates.
3. The system according to claim 2, characterized in that, The automated traffic flow generation module also includes a ground alignment unit, which detects the ground below by emitting rays from the vehicle's planar coordinate position and uses the detected collision point height to correct the vehicle's world space height.
4. The system according to claim 1 or 3, characterized in that, The automated traffic flow generation module updates the vehicle position in each frame: it calculates the new travel distance of the vehicle along the spline based on the preset speed and frame interval, then recalculates the world space transformation of the vehicle based on the new distance, and updates the display of the corresponding vehicle instance in the rendering module by calling the interface function for updating instance transformation.
5. The system according to claim 4, characterized in that, Before updating the vehicle's position, the vehicle's automatic obstacle avoidance module emits a ray forward from the vehicle's current position to perform collision detection. If an obstacle is detected, the module will switch driving routes or stop actively depending on the obstacle.
6. The system according to claim 5, characterized in that, The system operates as follows: Step 1: Instantiate the system in the 3D scene and match it to the road geometry in the scene by editing the splines of its path definition module; Step 2: Set traffic flow attributes, including the number of lanes, vehicle speed, and vehicle model, through the user interface of the parameterized configuration module; Step 3: The static generation module automatically responds to the configuration in Step 2, generating and previewing the static distribution of vehicles in the editor; Step 4: Start the program and let the dynamic control module take over. Calculate and update the dynamic transformation of each vehicle instance along the spline frame by frame to form a continuous traffic flow animation.
7. The system according to claim 6, characterized in that, In step three, when generating the static vehicle distribution, the lane offset distance Offset is calculated using the following formula: Offset = (LaneIndex - 2NLanes - 1) × WLane, where LaneIndex is the lane index. $N_{Lanes}$ represents the total number of lanes, and $W_{Lane}$ represents the lane width.
8. The system according to claim 6, characterized in that, In step four, the dynamic control module also executes obstacle avoidance logic, which means that before calculating the new position of the vehicle, it first performs forward ray detection and adjusts the effective driving speed of the current frame based on the detection results.