# Speed tree leaf flicker when HISMC add/remove/update instance

**URL:** <https://forums.unrealengine.com/t/speed-tree-leaf-flicker-when-hismc-add-remove-update-instance/266156>\
**Category:** C++\
**Tags:** General, unreal-engine, UE4-26, question, UE4-27\
**Created:** [December 14, 2021, 5:25am UTC](https://forums.unrealengine.com/t/speed-tree-leaf-flicker-when-hismc-add-remove-update-instance/266156 "2021-12-14T05:25:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anonymous\_a7a8733fdcba68559ef451bd664f59e7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_a7a8733fdcba68559ef451bd664f59e7](https://forums.unrealengine.com/u/Anonymous_a7a8733fdcba68559ef451bd664f59e7)\
**Post date:** [December 14, 2021, 5:25am UTC](https://forums.unrealengine.com/t/speed-tree-leaf-flicker-when-hismc-add-remove-update-instance/266156/1 "2021-12-14T05:25:02Z")

</div>

To reproduce this problem, i write a function like this

```auto
void UMyBlueprintFunctionLibrary::BeginRandomFoliage()
{

	if (auto IFA = AInstancedFoliageActor::GetInstancedFoliageActorForCurrentLevel(GWorld))
	{
		TMap<UFoliageType*, FFoliageInfo*> FoliageMap = IFA->GetAllInstancesFoliageType();
		for (auto& PerTypeFoliage : FoliageMap)
		{
			UHierarchicalInstancedStaticMeshComponent* HISM = PerTypeFoliage.Value->GetComponent();
			if (HISM->GetInstanceCount() > 0)
			{
				static bool bLeft = false;
				FTransform Transform;
				HISM->GetInstanceTransform(0, Transform);
				Transform.SetLocation(Transform.GetLocation() + FVector(0, bLeft ? 100 : -100, 0));
				HISM->UpdateInstanceTransform(0, Transform, false);
				bLeft ^= true;
			}
		}
	}
}

```

and call it at the level blueprint

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/b/b/bb6308e894fbb01308de16896731383e9bf4acfb.png)  
then like this,  
 ![2](https://d3kjluh73b9h9o.cloudfront.net/original/3X/b/8/b8a9d406465a5a154ff2f3a56e5da80f80007cbf.gif)

I update instances[0] transform per 0.1 sec only, but why instances[1…n] is flicker?  
but if i spawn a static mesh of this tree(non-instance), it works normally.  
 ![3](https://d3kjluh73b9h9o.cloudfront.net/original/3X/4/b/4bdfb81274e7fc71984fe8081483aa8b17e1eb81.gif)

it is speed tree bug?  
I noticed that issue [Unreal Engine Issues and Bug Tracker (UE-61559)](https://issues.unrealengine.com/issue/UE-61559), is it caused by the same reason?  
how can i do to avoid to that?

---

<div class="post-metadata">

**Author:** ![Anonymous\_a7a8733fdcba68559ef451bd664f59e7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_a7a8733fdcba68559ef451bd664f59e7](https://forums.unrealengine.com/u/Anonymous_a7a8733fdcba68559ef451bd664f59e7)\
**Post date:** [December 14, 2021, 5:31am UTC](https://forums.unrealengine.com/t/speed-tree-leaf-flicker-when-hismc-add-remove-update-instance/266156/2 "2021-12-14T05:31:04Z")

</div>

> [@Anonymous\_a7a8733fdcba68559ef451bd664f59e7](#):
>
> but if i spawn a static mesh of this tree(non-instance), it works normally.

BTW, I profiling the scene using render doc, and find out it seems get trouble at prepass

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/e/a/ea45dfab0cf57d406adea7ee21c4f7c373002f8a.png)
