Download

MarkRenderStateDirty() causes crash

Hi

I have a UInstancedStaticMeshComponent “Swarm” and I want to move one of its instances.
The code below crashs at the last line.
The Error Message is:
Assertion failed: IsValid() [File:D:\Build++UE4\Sync\Engine\Source\Runtime\Core\Public\Templates/SharedPointer.h] [Line: 890]


Swarm->PerInstanceSMData[SwarmInstance[i]].Transform = FTransform(NewInstanceRotation, NewInstanceLocation).ToMatrixWithScale();
	
Swarm->ReleasePerInstanceRenderData();
Swarm->MarkRenderStateDirty(); //this line causes the crash

Has Someone an idea what i am doing wrong?

Why you call ReleasePerInstanceRenderData()?

If I skip this line nothing happens, because the Transform Change is not noticed.

Did you try UInstancedStaticMeshComponent::UpdateInstanceTransform?

In ISMC source code ReleasePerInstanceRenderData is called only at destroy time (BeginDestroy and destructor)

Thank You so much :slight_smile: