Destroy spline meshes after a few minutes which spawns every tick.

Hi.

I am trying to delete an spline mesh component which is spawning by ‘Add Spline Mesh Component’ node every tick.

But I can’t.

I am managing spline meshes in an array.

I tried the followings.

I tried to destroy with ‘Set Timer by Event’ at the end of spawning nodes, but it doesn’t execute because it calls every tick.

I tried to set life span ,but there is no ‘set life span’ node to component. It is only able with an actor.

What can I do?

Instead of an array of SplineMeshComponents, make a struct with a float and a SplineMeshComponent and keep and array of them, call the float ‘Creation Time’ or somesuch, populate it with ‘Get Game Time In Seconds’.

Then at the end of your tick, in a while loop (condition: GetGameTimeInSeconds() -SplineMeshes[0].CreationTime > MAX_LIFETIME) destroy mesh and remove struct from array.

Arrays aren’t a great choice if you’re constantly pulling things off the front of them, but that is another issue :wink:

I Sloved the problem.
Thanks a lot!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.