Help on visualizing nodes

a string is an array of chars this is from the C programming language definition.

  • technically it is a pointer to char, and C allows for a memory offset to be applied to any pointer, and therefor any pointer is technically an array, this is still technically usable in C++, but this kind of pointer magic can lead to problems very quickly, and should be absolutely avoided except as a last resort, or hacking.
  • technically a string is a uint8-array, while an array of ints is an int32-array but the step of converting from int32[]->string->int32[] will obliterate the cache savings of passing a string opposed to an array of integers.

in C style languages (yes blueprints qualifies as many of the nodes are raw C++ and the rest are C++ derived assembly after being abstracted through a VM) an arrays index is an integer, so if you are holding the spawnpoints in an array, then you can take an array of ints and as long as they are “in bounds” of your spawnpoints array they can be used as indexes.

so I would suggest is:
I will be presume this is some kind of SpawnController actor that will have an array of either Actor-references, or SceneComponent-references (though this could be done with raw transforms it will be more book keeping)

  • make a member variable for your blueprint being an array of integers I will call it SpawnOrder
  • change the values of SpawnOrder to be your desired initial values (in this case [1, 2, 3, 4] )
  • pull over the SpawnOrder array from the variables section, and drop it near the BeginPlay (selecting “Get”).
  • out of the pin on the array reference pull out and release searching for “Shuffle”
  • attach the BeingPlay output exec-pin into the input of the shuffle
  • create an event dispatcher for SpawnEnemies (in the outliner of the blueprint under EventDispatchers hit the circled plus)
  • pull out SpawnEnemies and drop it selecting “event”
  • in the properties of the event node add an integer Array
  • out of the exec pin on the event or the array pull out and search for “foreachloop” (connect the one you didn’t pull out from)
  • pull over the SpawnPoints array (Get) and get the “length”
  • out of the loop body search for “if” or “branch” (both get you to the branch node)
  • out of Array Element pull out Greater then (putting “-1” in the second input), and also a Less then (attaching the SpawnPoints->Length into the other input)
  • pull out from one of the comparisons and get “Boolean And” (attach the other one you didn’t pull out of) and remember to attach the output of the and into the condion of the Branch.
  • out of true on the branch “do your spawning”
  • out of false I would suggest a Log String for sanity reasons
  • if pulling the SpawnEnemies off the Event Dispatchers section and selecting “Call” gives you one with the array input then attach that to the output exec of the Shuffle, otherwise out of the output pin search for “SpawnEnemies” which that one should have the input.

this is what I ended up with you don’t have to match my spacing or spaghetti shape (I did most of this spacing for a single screenshot) just so it is understandable to you.

if you are comfortable then you can do away with taking the input into the SpawnEnemies event but then you would need to absolutely expose the SpawnOrder array for external editing and trust that it is “appropriate”. if these are going to be “randomized” every time the SpawnEnemies is called then the shuffle can be part of the SpawnEnemies instead of BeginPlay,

there is no requirement for SpawnOrder to be of the same size as SpawnPoints just that any given element in SpawnOrder is within bounds of SpawnPoints, so if SpawnPoints has 10 elements, spawnOrder can have 0-10 elements (if you are not doing book keeping then you could have infinite elements in SpawnOrder) as long as any given element is within the bounds of SpawnPoints length.

1 Like