I am working on a tank game atm and I made some tracks for the tank. In my case I just want the tracks to rotate in circle (like wheels), so basically no suspension, no real tank wheels, simply not a real vehicle.
I made my own tank tracks using no tutorials. It works, but if I look at the code it looks bad and it is definitely not how it should be done. I can feel that it kinda hurts my game performance. Probably because of many meshes or the way the single track components rotate.
Here is the way I did it:
this is how the track looks like
I have a spline with a bunch of splinepoints and on the splinepoints I spawn a mesh and save each mesh in an array
Each track has its neighbor. So Track with index 0 has neighbor with index 1, Track with index 1 has neighbor with index 2 and so on. But Track with last index has neighbor with index 0.
Now I take Track Index N and move it overtime to the transform of its neighbor.
Now thats where it gets weird. I do it with all Tracks.
It doesnt work in for loop. Loop doesnt support OverTime functions. Nothing happens if I do it in a for loop.
Now when I press A or D a message is sent to the Tracks BP where a timer starts and loops until I release the button.
Here is video of Tracks in work.
I dont really like my solution. I think its bad and not efficient. Does anybody know how I can improve or do it otherwise? Maybe someone can recommend me a good and understanable YT video?