# Hierarchical instanced static mesh component crashing when compiling blueprint

**URL:** <https://forums.unrealengine.com/t/hierarchical-instanced-static-mesh-component-crashing-when-compiling-blueprint/373277>\
**Category:** Blueprint\
**Tags:** Hierarchical-Instanced-Static-Mesh, unreal-engine, crash, bug-report, CPP, Blueprint, question\
**Created:** [October 13, 2016, 10:43pm UTC](https://forums.unrealengine.com/t/hierarchical-instanced-static-mesh-component-crashing-when-compiling-blueprint/373277 "2016-10-13T22:43:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vle07](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@vle07](https://forums.unrealengine.com/u/vle07)\
**Post date:** [October 13, 2016, 10:43pm UTC](https://forums.unrealengine.com/t/hierarchical-instanced-static-mesh-component-crashing-when-compiling-blueprint/373277/1 "2016-10-13T22:43:44Z")

</div>

The editor crashes trying to access an out of bounds array index from the hierarchical instanced static mesh component.

**Steps to reproduce:**

1. Create a c++ class inheriting from the actor class
2. Add a UPROPERTY(EditAnywhere, BlueprintReadWrite) UHierarchicalInstancedStaticMeshComponent\* InstancedStaticMesh
3. Add a UPROPERTY(EditAnywhere, BlueprintReadWrite) float InstanceCount
4. Use CreateDefaultSubobject to create the hierarchical instanced static mesh component
5. Add the function OnConstruction(const FTransform& Transform)
6. In the OnConstruction function, call InstancedStaticMesh-\>ClearInstances(), and then add a for loop from 0 to InstanceCount calling InstancedStaticMesh-\>AddInstance(FTransform()) every loop (maybe add a translation so instances won’t overlap).
7. Create a blueprint inheriting from the c++ class
8. Assign a mesh and material in the details panel for the hierarchical instanced static mesh component
9. Change InstanceCount to 1
10. Save and compile the blueprint, it should work the first time
11. Change the InstanceCount to 2. The blueprint viewport should update showing a second instance added
12. Save, then try to recompile the blueprint and it should crash
13. If you relaunch the editor, you’ll notice the blueprint now has InstanceCount at 2 (because it was saved before the crash), and there are 2 instances
14. Change InstanceCount to 3, 4, 5, 6, notice every time the blueprint viewport updates accordingly
15. Try to compile and it’ll crash again

This doesn’t happen with normal instanced static meshes. Nor does it happen when adding instances in the blueprint Construction Script node. I don’t think it happened in 4.12 either, just 4.13.

**Another bug that’s probably related to this issue:**

1. Create a c++ class with a UInstancedStaticMeshComponent
2. Create a blueprint inheriting from this class
3. Change the UInstancedStaticMeshComponent to UHierarchicalInstancedStaticMeshComponent
4. Try to compile with a hot reload in the editor and it should crash
5. Build the solution in visual studio
6. The editor will fail to launch as long as the blueprint in step 2 exists

The only way to get the editor to launch again is to change it back to UInstancedStaticMeshComponent and rebuild. You can only change a UinstancedStaticMeshComponent in a c++ class to a UHierarchcialStaticMeshComponent if there is no blueprint that currently inherits from that class.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61b4a355](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61b4a355](https://forums.unrealengine.com/u/anonymous_user_61b4a355)\
**Post date:** [October 14, 2016, 1:23pm UTC](https://forums.unrealengine.com/t/hierarchical-instanced-static-mesh-component-crashing-when-compiling-blueprint/373277/2 "2016-10-14T13:23:42Z")

</div>

Hey vle07,

Thanks for the detailed report. I was able to reproduce the issue and have entered a issue report for it. You can follow it here:

[https://issues.unrealengine.com/issue/UE-37316](https://issues.unrealengine.com/issue/UE-37316)
