Hey-ho,
is it possible to merge splines ingame?
Why I’m asking:
I’m working on a train (and rails) and the train has to move along splines (at least this seemed the best approach).
The splines are attached to the single railtracks. So if the player places a railtrack (100u x 100u) there is also a spline (100u).
The function (Event Graph of the train, no own c++ code) works like this:
Find the nearest spline (*get all splines in the world and look whats the nearest one) and move the train along this spline. When the train reaches the end,
look for the next spline and continue the movement along this one.
But… I assume the scanning for the nearest spline every 100u will consume a lot of performance
when there are thousands of railtracks on a server.
So I thought, connecting the new placed spline to the existing one and merge it,
as soon as the player places the track, would result in one long spline per railway,
and much less scans.
And here is my next question:
Can I split splines ingame?
Well, when the player removes a railtrack… ![]()
*I’m using GetAllActorsOfClass class=railtracks and a ForEachLoop to loop through all position and calculate the shortest distance.
If there is something like a GetAllActorsFromClass_within_a_range or something else that gets the next spline without scanning and looping
through all the other splines, that would help too.
Because I don’t know if merging splines helps me with track switches.
I hope my explanation is clear enough.
Help would be greatly appreciated.
Edit: in the meantime I came up with another apporach, but I’m not really sure about this.
I could store the position of the previous rail track in a variable of the actual track at place-time.
Then store the position of the actual rail track in a variable of the previous track.
Everytime a player starts the train or changes/add a track, the path gets updated in the train.
This would even solve the problem with switches ![]()
But the first approach would be more performant anyway ![]()
Best regards,