# How to add function in the C++ "Class '/ Script / Foliage.FoliageInstancedStaticMeshComponent'

**URL:** <https://forums.unrealengine.com/t/how-to-add-function-in-the-c-class-script-foliage-foliageinstancedstaticmeshcomponent/211204>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [March 30, 2021, 5:34am UTC](https://forums.unrealengine.com/t/how-to-add-function-in-the-c-class-script-foliage-foliageinstancedstaticmeshcomponent/211204 "2021-03-30T05:34:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suundumused](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/suundumused/32/599389_2.png) [@Suundumused](https://forums.unrealengine.com/u/Suundumused)\
**Post date:** [March 30, 2021, 5:34am UTC](https://forums.unrealengine.com/t/how-to-add-function-in-the-c-class-script-foliage-foliageinstancedstaticmeshcomponent/211204/1 "2021-03-30T05:34:48Z")

</div>

I am not experienced in C ++ but in version 4.19 onwards they removed the option “Use Dynamic Instance Buffer” from the child class blueprint created manually from the “C ++ FoliageInstancedStaticMeshComponent” of the engine, now I need to add the function in C ++ in this asset to be able to remove and add instances of the foliage during play in Standalone or packaged.

On this website show my blueprint code: [Part 1 Access posted by anonymous | blueprintUE | PasteBin For Unreal Engine 4](https://blueprintue.com/blueprint/x2yhbc6h/) Sorry for the graphs are a little cluttered.

The purpose of this graph is to obtain all instances of a foliage static component from the foliage actor and remove all instances of the specified instantiated static mesh “index 4” it gets the reference correctly, but when removing the instance it returns true but nothing happens.

I saw in this forum that following these procedures, the ones I located in the first phase, I would be successful, but in the part of activating the option “Use Dynamic Instance Buffer” I was unable to proceed because the option does not exist in the latest versions of the engine so mine solution is to add this function in C ++ in Class ‘/ Script / Foliage.FoliageInstancedStaticMeshComponent’ but I don’t know how to do it, could you help me?

> **[Remove Instance node works in editor but not in standalone game?](https://forums.unrealengine.com/questions/749492/remove-instance-node-works-in-editor-but-not-in-st.html)**
>
> Hello guys! I’ve encountered a strange behavior with Remove Instance node. The following blueprint is supposed to delete foliage instances around my character. It works just fine in the editor during play and/or simulation, but doesn’t in a...

---

<div class="post-metadata">

**Author:** ![Suundumused](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/suundumused/32/599389_2.png) [@Suundumused](https://forums.unrealengine.com/u/Suundumused)\
**Post date:** [April 4, 2021, 5:27pm UTC](https://forums.unrealengine.com/t/how-to-add-function-in-the-c-class-script-foliage-foliageinstancedstaticmeshcomponent/211204/2 "2021-04-04T17:27:46Z")

</div>

Any idea???
