How can I snap instanced static meshes to the landscape? (spline tool)

The problem is here:

You pass in the Instance Index from an array that is actually made up of multiple Instanced SM components. For example, you have 3 components, each with 1 instance. If you use a For Each like in the screenshot, you’ll only find the first instance of the first component. That’s because the second iteration will look for index 1 in the second component, and index 2 in the third component — but all of them only have one instance, at index 0.

Instead of storing your instances like this in an array, which seems error-prone, I’d suggest using built-in functions like Get Instance Count. For example, something like this:

With this nested For Loop you’ll loop through all of your components and all of their instances, without needing to track the numbers yourself.

1 Like