Mapping a class to an integer

Hey all. I have a function set up to spawn part of a level every so many steps the character takes. The character only walks in one direction so it creates an infinity generating map. I want to reuse this function for each level, where each spawning class is different depending on the level. How can I map the Spawn Actor By Class block to spawn a class depending on a variable I can save somewhere (then i can just edit the variable when the player picks a level)?

  • a Select node:

Or a slightly more optimal:



  • a Switch:


  • an Array:


There are more ways, a Data Table can fetch by index since it’s a glorified Map anyway.

I have a function

You can have the function accept an Int parameter and feed it from a Save Game Object the player loaded. This way there’s no need for another variable. Could work.

2 Likes

Great answer thank you. Now let me complicate it a little more. Lets say that the level “part” that spawns now has multiple types. So each spawn section is a different class. So I can set 1 class equal to 1 reference value, but how do I set multiple classes to 1 reference value?

Update: I ended up using Random Int in Range block, then referenced the Min to my LevelSelect variable, then set my max to LevelSelect +3. This way as long as I have the same amount of classes per level, I can just use that range with min being mapped to the first class of that series. I hope that makes sense :slight_smile:

Inheritance:

You contain the shared functionality / components / variables / logic in the parent. And the children can inherit or override it.

2 Likes