Help on visualizing nodes

hello, i am very new to blueprint and i need help visualizing these blueprint nodes. and to understand them better while they are simulating.


can you be more specific on which of these nodes you are having trouble with, or is your question how to attach them?

I am not particularly sure why it is suggesting:
take an array of ints->Shuffle->convert to string->then convert back to integers->only then worrying about zero-based indexing
– convert to string to go back to ints is a waste of cycles (it is saner to pass the array, or leave the array as a member variable so you don’t have to even pass it), and you should be worrying about zero-based indexing every moment dealing with arrays (it is something you get used to in programming as the #1 reason for out of bounds exceptions)

  • you can post formatted text by using the "`"x3 (button left of 1 in your number line) on a line then line break and do it again. anything in between those 2 lines will be formatted text
  • you can post block quotes with the Greater than “>” at the start of the line.
  • images can be difficult on mobile, and cannot be translated so people that do not necessarily know the written language can still potentially help.

im having trouble on where to attach them together and how it should look like. Also you were saying that there is a better solution?

My goal for this code is I want to have 4 spawn locations for an enemy. I want to have a string that determines where an enemy will spawn an at which of the 4 locations. In this string I want the order to be random based on which value in the string is picked.

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