Add HISM logic for crowd system

Stuck on proper Blueprint logic for a crowd instancing system in Unreal.

I am instancing a small number of unique crowd agents (static meshes) targeting a collection of vertices in a target mesh. So 2 arrays. Small one containing my unique crowd agents. And a large one containing the vertex positions.

After a lot of digging I realize what I have (in attached) is wrong.
I need to be only adding a new HISM for each unique character (static mesh) NOT for every single instance(vertex postion).

What change(s) should I be making to the attached?

I don’t actually understand the code you have there, but you’re right. You only need to make HISM for each different mesh. It looks like in this case, that’s your characters.

So my revised logic would be
1 Define my current characters array containing my unique static mesh actors.

2 Based on this array add a new HISM component

3 In my ‘main’ execution thread create my array of vertex positions.

My confusion is what to do with the execution thread after the AddHISM component (green question mark)?
or in other words how to connect the 2 execution loops?
I definitely can’t nest them (ie have 1 for loop in the Body of another one).

You loop and add the HISMs, keep a reference to each one in an array.

Then go through the array and add instances of each of the HISMs, you can manipulate the instances.

So I would create a 2nd array, lets call it HISMArray

Then the result or return value of the AddHISM component I would add or append to this array.

2 issues

1 Blueprints doesn’t seem to have any generic Object Variable Type Arrays

2 For this to work doesn’t the Array Element of my ForEach Loop have to be connected to the Target of the AddHISM component?

To your issues

  1. They are all static meshes, you just have to remember what types.

  2. The first loop will make N HISMs, you put them in the array. These are the HISM refs. Each HISM can only be one type of mesh.

You then run through that array, and make instances of each one. Each instance can be references using an index later.

Come back if you don’t get it, and I’ll drop a bit of code in…

Here’s a basic example

So you see, I make all the HISMs and put them in an array ( and set the mesh ), then I loop through the HISMs and place instance of them.