How can I make an event happen randomly

I’m working on a project where something randomly attacks, and I can’t find out how I can make this randomly happen with blueprints.

Hi there is this using behaviour trees for the ai or a simpler method?

The question is too vague, here’s a generic 25% chance of attack:

Consider describing what you’re trying to achieve in more detail.

What I’m doing is trying to make a horror game using blueprints, where you get randomly attacked whilst in the woods, and I can’t find out how to make it happen randomly.

What does it depend on? Proximity, timing, location. Give us something to work with, heh. Otherwise, just run the above on a timer every 10s and there you have it.

I would like it so that it can’t happen in certain areas, but whilst you are roaming around you can get attacked.

Place an actor with a volume. When the player enters the volume start checking if there is an attack. You can hook up what I posted to a timer, as suggested.

Or have a safe zone (an actor with a volume) switch it off when entered.

Thanks mate, that’ll help

I would like it so that it can’t
happen in certain areas, but whilst
you are roaming around you can get
attacked.

I created an actor with a sphere collision - that’s the safe zone.

When the player leaves that zone, we start a timer and there’s a 50% chance that every second something falls on the player - a new actor is being spawned here above the player. When we enter the zone, the timer stops.

Image from Gyazo

Wow thanks for that, I’ll upvote you