UpdateInstanceTransform() messes up Per Instance Random

Calls to UInstancedStaticMesh::UpdateInstanceTransform() causes the instance to get assigned a new “per instance random value” inside FStaticMeshInstanceBuffer::UpdateInstanceData(). Was not an issue in 4.16.

This will be fixed in 4.19. Sorry for the delay but to fix it, it end up changing some interface, which mean it can’t go into 4.18.X

NOT CONFIRMED: still seeing the problem in 4.17.2

Same problem here. not fixed in 4.17.2 or 4.18…

This is frustrating. I really need this feature, too. This is preventing me from upgrading to 4.17 or 4.18. I had to go back to 4.16.

Also waiting for this. Wish there was a way to manually set per instance random value in CPP or something.

Can someone please fix this! It is still broken in 4.19.
I am trying to sell an asset on the Marketplace which requires this to be fixed.

Can you provide some context on your issue? How are you using the system, etc…

Thanks

I am using the HISM system. I update each Instances Transform every tick to animate along a spline.

There are two bugs i have run into. If I manually create instances within the HISM system, there appears to be twice the amount of instances when the level starts.
If I manually add 10, i play the level and there are now 20.
I can solve this by removing the additional instances upon Begin Play.

The other issue is that the PerInstanceRandom value seems to randomly change. I have created a demonstration project for you to check here.

Download Example Project

The project contains a bunch of spheres that move along a spline.
Each of the spheres has a color which is set by the PerInstanceRandom node.
The sphere’s randomly change colors when they should not.
There are two possible causes: Either the spheres are switching places, or the PerInstanceRandom node is changing value.
I have proven that the spheres do not switch places by providing their locations in Print String.

You can see all of this with documentation inside the project I have provided.

Hi i’m currently looking at your sample, and see your using HISMC. You realized that in the case of your sample it’s really not an optimal way of achieving what you want do to right? You should really use the ISMC (it wont solve your issues, it’s simply really not optimal performance wise what you’re doing). Considering also that instance order is not guaranteed using HISMC, if you perform add/remove operation and that EVERY frame right now you rebuild the cluster tree (spatial organization tree 20 times)…

P.S when loading your data you really have 20 instances added and saved.

10 in the BP which got transferred to your instance(normal behavior), AND 10 added into your instance also. Care to explain if you perform this manually or what you did to achieved this?

See the screenshot:

So after more investigating, if you use an ISMC there is no bug, all is working fine, except that in your Update Instance Transform you should set Mark Render State Dirty to true on the last one, to force the refresh of the Render state.

As for the problem when using HISMC, the thing with HISMC is that it will reorder instances for visibility culling/occlusion, which mean changing physically the place of instances in the buffer, which give the visual issue you’re seeing, i’ll investigate some more if there could not be an issue there, but unless the test project really do not match what your do in your actual project, i see really no reason for you to use an HISMC, it’s more costly and do not do the behavior you want to do.

Unless you have +1000-2000 instances HISMC do not make sense to use at all.

Hi Michael, thank you so much for your help on this issue!
I did originally plan on using over 1000 instances with the blueprint, as I have created a “Fish School System” which can be used for virtually any swimming sea life, including thousands of jellyfish. It was working perfectly with HISMC’s in Unreal 4.16, but the upgrade to 4.17 broke it.
Its a bit annoying that I cannot sell it on the marketplace for previous engine versions (as this would include the majority of my sales), but I am glad that can at least publish it for the latest engine version, and include it in the game I am working on.
Again, thank you! You’ve saved my entire week of work from being wasted.

Hi there, I just ran into this problem myself and I understand why it’s happening, but really hope it can be fixed. HISM’s are vital for my project and adding an instance makes a complete mess on screen. Thanks for your help!

Hi, can you provide some context on your usage? What is your setup?

Thanks

Is there a CL# for this fix? Our project is going to ship with 4.18 but I could really use this