How to spawn actors randomly?

Hello everyone, (hablo español por si alguien me puede responder en mi idioma).

I’m having a problem making it randomly spawn specific actors when the character hits the trigger box collision.

I tried to create a Array and put them all together but the actors would NOT let themselves connect to the matrix and neither would the spawnactor.

I don’t know how to solve it.
I’m still learning and I don’t understand English very well.
I thank you for the help.

Hi, If I understood you right, you need to create an array and then fill it manually.
After that, you can easily pick a random actor class from this array

3 Likes

Hi Riezez,

Yaklakootmaa is spot-on with their answer. (Using ‘random’ function).

But here’s a different (admittedly more complicated) way to do the same thing. Takeaway here is that arrays are zero-based (the first item is at position 0). So if you’re seeing ‘off by one’ problems that could be the cause.

If you enable ‘Instance Editable’ on the array variable, you’ll be able to set the actors per-BP once the BP is placed in the level.

Hope that helps!

3 Likes

Ty so much.
your solution works perfectly.
Now the arrowcomponent are corrupted but I know how to fix it
Once again, ty so much.

2 Likes

Ty so much.
Your solution works for me too, it is also a bit complicated.
Now I understand much better how that function works.
Again ty so much.

1 Like