It was jut a simple example I’ve made to show someone how to do it, but if you actually want to do it efficiently, you may want to cache the reference for the component in a variable so you don’t have to cast every time.
So the result of a physics query ( like a linetrace) will return a HitResult for each shape it hits. The HISM maintains a shape for each instance. So you will get a HitResult for each instance, with the instance identified by HitItem.
With that said, what exactly are you trying to do?
The HISM already partitions the instances for culling . It automatically creates clusters of instances and culls and LODs them.
That is the difference between HISM and regular ISM.
eg if you are in the center of the asteroid field facing north, any clusters that are entirely behind will be culled.
You can validate this using one of the stat tools (cant remember which command)
Yeah - testing and removing instances on tick via line tracing might not be the best thing performance wise. BTW - the LineTrace node above is not needed at all in that screenshot - you can just calc the distance directly from instance and ship locations. But you dont want to check every ship every frame anyway.
How do you know the HISM isnt culling?
A fun way to verify culling is to use ~FreezeRendering, then use ~ToggleDebugCamera to eject and fly around the map. You can see what isnt being rendered this way.
Be sure to check the culling properties on the hism component. By default they are set to not cull.
As a simple alternative, you could also just partition your map into multiple ism components. These should cull when entirely outside view frustum.
I find this tool very useful for working with instances: