I’m spawning instanced static meshes via an actor blueprint using the “AddInstanceWorldSpace” function, and once I reach 128 of them, no subsequent instances spawned in that blueprint actor have collision. They do not collide with the player, nor do they generate trace events.
~I’ve tested this both with using simple collision as complex, and also with simple collision boxes.
~I’ve confirmed that once you hit the 128 limit, you can spawn a different set of instanced meshes within the blueprint and they will have collision for the first 128 copies.
~The issue does not exist if you set the instanced mesh to be static and not movable.
This is severely limiting the usefulness of instances, because you can’t manage or delete them unless you can get a ref to them by tracing.
I just came upon this problem trying to loop thru all the instances in a InstancedStaticMeshComponent. When hitting the 129 instance in the loop (index 128), it crashes. Mine component was set to Movable, and this is fixed when setting to Static as you said, but I’m curious why that’s happening also.
I have been able to reproduce this effect on my end and have entered a bug report, ttp#348924 to be assessed by the development staff. For now, please use static meshes instead of instanced static meshes until we can get to the root of this bug. Thank you!
I have one more question about speed… I have a simple grid of these instanced static meshes, all updating positions every tick with [UpdateInstanceTransform], simply oscillating their Z-values. I did some profiling because you can see in the screenshot below, the frame time when the grid is 41x41 squares is pretty extreme. The profiler says the rest of the app is basically waiting for the “Phys SetBodyTransform” to finish, which takes ~50ms every frame, and is called 1681 (i.e., 41x41) times. I was wondering if it’s a bug that it’s this slow of a call, or if it really is just gonna take that long to update that many instances.
How many instances are you spawning at one time when this occurs? I just attempted an instanced mesh blueprint with 500 actors in it and all had collision as intended. Do you have repro steps I can take to reproduce this on my end?
You tried an instanced mesh blueprints with 500 Actors in it? I don’t really get what you say, do you call Instances “Actors”?
Just create an Blueprint, add an Instanced Static Mesh Component (I use the Hierarchical Instanced Static Mesh Component) and add 500 Instances. Once you exceed 128 instances your output log will get spammed with the PhysX Warning.
I attempted this with the Hierarchical Instanced Mesh Component as well and received the same results. Collision worked on all objects and no errors appeared in the Output log. Are you using a specific mesh that is creating this error or does this occur in a new, blank project with base assets?