Random Spawn system

What would be the best way to tackle making a spawn system like final fantasy 7 where you run around the map and you spawn into a fight that is turn base. I know it’s a tall order but I’m looking for the best place to start.
Cheers

Hi Deftones4,

Making a random spawn system is very easy - the hard part is making the turn-based combat that comes afterwards :slight_smile:

This is one way you can do the random enemy encounter:

-Create a custom event inside your CharacterBP (call it EventRandomSpawn) and have the event call a timer (for now make the timer loop every 1 second).
-Inside the timer you are going to use the node “Get Random Float in Range” and make the min 0 (0%) and the max 1 (100%)
-Create a Float variable and name it “PercentToSpawn”
-Then you are going to get the result from “Get Random Float in Range” and see if its >= to (1 - PercentToSpawn).
-Drag this into a Branch. If True, random enemy spawned, if False, do nothing.

The formula looks like this:

RandomFloat(0,1) >= (1-PercentToSpawn) -> True? Spawn Player into combat with enemy; False, do nothing.

So, lets say you want the enemy to spawn 10% of the time. Make PercentToSpawn = 0.1. The formula looks like this: RandomFloat(0,1) >= (0.9).

Now notice that you are basically doing this check every second (based on your timer setting), so if you want to check more often, make the timer loop quicker. Play around with the timer loop and the PercentToSpawn to get something that feels like. I wouldn’t make the PercentToSpawn too high, or it will feel like they are always getting into a fight.

Unfortunately Im not infront of my dev machine or I would share a screenshot, but hopefully the descriptions above get you on the right track.

Hope it helps!

Thanks for the feedback it really helps do I assume that I want it to spawn actor from class and put in my enemy BP ? Cheers

Well, it depends on what you want to do at that point.

If you are going the classic RPG route, then you want to spawn the Player in another map (battle map) that has the enemies. So in this case, I would advice using Level Streaming to load a sublevel and THEN in that sub-level use Spawn Actor from Class to spawn your enemies.

If you just want to spawn the enemy on the current map (world map), then yes, just use Spawn Actor from Class :slight_smile: