Despawn/Spawn actor from a datatable

Hello im im making a lasercutting machine in UE 5 and my logic to spwn the laser worked fine:

Now im trying to turn it on and off with a column in my datatable but i cant get the bp to work. Anyone has an idea where my mistake is?


Thanks a lot in advance. ;D

Why are you destroying the laser actor? Why not switch it on / off?

1 Like

The destruction isnt necessary I just dont know another way to turn it on/off :sweat_smile:

So… what is not working about it? Do you get an expected on / off triggers from the switch? The script looks OK at a glance.

Oh, I see - it probably goes through the entire DT in a split second?

1 Like

What do you mean by that?
Not working is that the laser doesnt spawn in anymore at all.

image

Put print string on ON / OFF. What do you get? A lot of spam?

I think you execute this ENTIRE thing in a single frame, no?

1 Like

I tried that and there are no Strings printed when i play the Level.

No wonder:

1 Like

I already fixed that but there are no strings printed :frowning:

What is the value of that integer that gets stuff from the DT and what is the first entry in the DT?

1 Like

table
This is how the table looks

Well, you Ignore the first one, so nothing happens. You start here and then nothing happens:

Event if hooked up, this whole thing will execute in a single frame; you never tell it to wait or how fast it should go. So it will do the entire thing at once if you give it the chance.

1 Like

When i connect ignore to the ++ note i cant run the level because it detects an infinite loop

Yup, as mentioned above. Add a delay node here:

image

Set it to .5s for now. You will also need to do something when you run out of rows in the DT. And the Switch Ignore has to be connected as well - probably just to ++


Once you have it hooked up and it still does not work, do show the updated script.

1 Like


Thanks for your help this works now i just got to figuer out how i can make it turn the laser off at the right times because i use the same DT for the movement of the laser the main level BP.

1 Like

Some notes that seem applicable:

  • consider incorporating the Delay data into the DataTable - each row can then dictate how much time needs to pass before we move to the next row. You will probably need some precise timing to drive this, right?
  • rather than Spawning & Destroying actors all the time, do it only once - on Begin Play:

So later on you can:

It’s very cheap to move / show / hide an actor, and expensive / cumbersome to spawn or destroy it.

  • similarly to the above, you can cache the names only once:

image

So you can…

…elsewhere in the script.

Good luck!

1 Like

Thank you for your huge support i appreciate that a lot. I’ll try to improve my BP :wink:

1 Like

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