1. Relevant knowledge about splines
Reference from: Spline Function - Steamed Buns and Hanamaki - Blog Garden
Cubic spline interpolation - Zhihu
B-Spline (3) Properties of spline curves - Fun With GeometryFun With Geometry
My personal understanding is not very deep, but what you need to know is that splines have local characteristics, and the curve of each interval is only related to the position and slope of the endpoints at both ends of the interval.
2. Use the ue spline component to make the object walk along a fixed trajectory
Reference from: ue4 spline curves to create motion trajectories_Stepping on the Sun's Blog-CSDN Blog_ue4 Creating Roads
1. Create a blueprint class and add the Spline component
2. Add several variables required for control
Mainly moveActor: used to control random moving objects, and speed: used to control the speed of movement. Make sure to open the eye next to the variable so it is exposed to the editor.
3. Use GetTransformAtDistanceAlongSpline function and SetActorLocationAndRotation function
3. Generate random spline trajectories
The key is to use the AddSplinePoint function. An additional ponitCount variable is added here to control the number of points in the generated random trajectory.
In addition, the SetSplinePointType function is also very useful, and can control whether the spline generates a rounded curve or a smooth curve.
The final generated path is as follows: