Dealing with RNG/Randomness

Evening all, I have a question/problem I’d like to pose to everyone in hopes of a solution or potential ideas, to get my think tank working!

So here it is:
I have created a (very) basic blue print of movement of an actor or in this case a trap that hits my player actor, once the player enters the “play” volume it begins the overlap and activates the trap movement, once they leave it reverses back to its original position. I plan to have several of these in one area however the problem I have is how to set them off individually or at complete random.
Do I set a delay on certain duplicates to start (which seems very long winded) or use the “random” nodes inside of blueprint? I’ve pulled off a few random nodes but to be completely honest I can’t see if they are affecting anything.

Any help is appreciated. I’ll leave a screen cap of my current blueprint.

Cheers!

Callum

You do get all actors of class >insert your trap blueprint here<, get random integer from zero to max index of all trap actors. And tell that trap to fire.

Trap blueprint should know if it was fired, and not fire again even if you tell it.

If you want to make one trap fire every time you just random trough them until you find unfired trap. Also for this counter of how many traps were fired would help.

Then you probably need some timer to fire those traps every second or so, not every tick.

This is not a good idea. If there is only 1 unfired trap left out of 50 then finding it will take a lot of random trial and error.
It would be better to have two arrays. One all-traps array, which is copied into an unfired-traps array. Whenever a trap fires, it is removed from the array.
You just pick a random in the index range of the unfired array.
Each access will guarantee to return an unfired trap. No branching, no comparison needed.
When the unfired traps array is empty, just duplicate it again from the all-traps array.

I don’t understand what it is your trying to do exactly. So some traps are set to fire at random intervals while others are set to fire when triggered by the player? If that’s the case, just have the RNG inside the constructor to determine if its an “interval based” or “trigger based” trap?

I feel like I’m completely misunderstanding you though…

That was easiest to implement version.

Optimal is that you store all trap references on begin play.
When trap is fired you remove that reference from array.

Also slowing down for traps fired may be desired effect. You never know.

Thanks for getting back so quickly guys! I’ll try the methods you told me here and let you know how it goes!

Apologies I should have made it a little clearer, I have a room set with a certain amount of traps (haven’t decided how many) and I wish to create a volume so when the player enters it, It will activate my trap blue print causing these traps to pop out of the wall at random intervals, instead of one after the other. I hope this has cleared up some of your confusion!

Thanks for the reply though I appreciate it!

Callum

I actually do like the two array version (fired / unfired).

I’ve still got no luck with this, I think I’m going about it all wrong, thanks for your help though folks!

Callum

Well, you can bake the RNG into the traps for an almost identical effect. Just have the trigger volume contain an event dispatcher that “activates” all the traps in the room, having them all count down from their respective randomized delays.

The previously mentioned ideas are also very good and will accomplish the desired effect