# 'Get Instances Overlapping Box/Sphere' not working as expected in UE 5.0

**URL:** <https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [April 16, 2022, 7:20pm UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779 "2022-04-16T19:20:15Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ferolynx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ferolynx](https://forums.unrealengine.com/u/Ferolynx)\
**Post date:** [April 16, 2022, 7:20pm UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/1 "2022-04-16T19:20:16Z")

</div>

Hey there,

I have a behaviour in my farming-like game where if the player puts down a patch of soil, I’m using ‘GetInstancesOverlappingBox’ or ‘GetInstancesOverlappingSphere’ to get any surrounding flora to be removed.

In UE4.27 this behaviour worked perfectly, however since updating to 5.0 I’ve noticed this is no longer working after the first plot of soil… e.g…

1. Player puts down one patch of soil. The flora around this is removed as expected.
2. Player moves and puts another patch of soil down, the flora is not being removed. Nothing is being returned correctly from the GetInstancesOverlappingBox/Sphere node.

I’ve recorded a small video of the behaviour.  
[debug farming - YouTube](https://www.youtube.com/watch?v=kNfhYCrRKfw)

Has a bug been introduced or do you think I’m doing something wrong here? Bearing in mind this worked before in UE4.27…

---

<div class="post-metadata">

**Author:** ![Countsie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/countsie/32/1194632_2.png) [@Countsie](https://forums.unrealengine.com/u/Countsie)\
**Post date:** [April 16, 2022, 8:08pm UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/2 "2022-04-16T20:08:30Z")

</div>

Hmmm, I’m still on 4.26 so I can’t check directly, but see if maybe there is a function in the FoliageHISM actor to rebuild the Foilage HISM cluster data after removing the first batch. Like:

`BuildTreeIfOutdated(true, true)`

I thought this was called indirectly when removing instances but I’m not positive on that, and things may have changed for 5.0

---

<div class="post-metadata">

**Author:** ![Ferolynx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ferolynx](https://forums.unrealengine.com/u/Ferolynx)\
**Post date:** [April 16, 2022, 9:01pm UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/3 "2022-04-16T21:01:04Z")

</div>

Thanks for the reply @Countsie , I did a diff between 4.27.1 and 5.0.0 on the HISM cpp, and couldn’t find anything out of the ordinary. Quite a few lines have changed but it looks like the `BuildTreeIfOutdated` logic has remained untouched. Although I noticed in both versions it was `(true, false)` instead of `(true, true)`.

Also, if I may ask - is HISM what I should be looking at? As `InstancedFoliageActor` and `FoliageInstancedStaticMeshComponents` are the items that are made here.

---

<div class="post-metadata">

**Author:** ![Countsie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/countsie/32/1194632_2.png) [@Countsie](https://forums.unrealengine.com/u/Countsie)\
**Post date:** [April 16, 2022, 9:55pm UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/4 "2022-04-16T21:55:06Z")

</div>

FoliageInstancedStaticMeshComponent inherits from HISM with hooks for the editor tools and a few other things, most functionality resides there or in it’s parent InstancedStaticMeshComponent.

the params are (async, forceupdate)… async does the rebuild on another thread, forceupdate will rebuild regardless if there is a change or not. I suggested (true, true) to make sure it did rebuild, but in practice you probably dont want to force the re-build.

Honestly, this may be barking up the wrong tree, but it was the first thing that came to mind if the Foliage HISM gets out of sync. You might be right… there may be a bug. I’m assuming the foliage painting/erasing in the editor work fine?

FYI for convenience you can manually rebuild by using the console command:  
`foliage.RebuildFoliageTrees`

You could try digging a spot, run the command, then dig another spot. This would at least ensure cluster tree is updated so you can see whether or not that makes a difference.

---

<div class="post-metadata">

**Author:** ![Ferolynx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ferolynx](https://forums.unrealengine.com/u/Ferolynx)\
**Post date:** [April 16, 2022, 10:25pm UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/5 "2022-04-16T22:25:49Z")

</div>

Thanks for that information about HISM, and explaining the arguments. I switched it over to `true` just to see if it made any difference, but alas it is still not working.

I also did `foliage.RebuildFoliageTrees`, but it still isn’t working. Which implies there might be something else going on.

I’ve had a bit of a mess around and now the problem has developed haha.

I repainted some of the foliage in the editor and now it’s not working at all. (yes the editor still seems to work)

However if I increase the size of the Overlapping check, it does seem to retrieve something, but the result seems way off. Foliage gets removed at a large offset away from where I’m digging in the game.

The other thing I’ve noticed is that despite running the removal on all foliage actors (grass\_varA, grass\_varB, flowers, plants, etc) it only seems to remove the grass type elements.

So yea, seems like something a bit funky is going on… ☹

---

<div class="post-metadata">

**Author:** ![Countsie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/countsie/32/1194632_2.png) [@Countsie](https://forums.unrealengine.com/u/Countsie)\
**Post date:** [April 16, 2022, 10:39pm UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/6 "2022-04-16T22:39:53Z")

</div>

Huh… make sure you’re passing the info in WorldSpace coordinates and setting the appropriate bool. Otherwise it assumes you are passing the box/sphere in local component space. Odd that your first shovel-load worked fine.

If you have lots going on in your map I would set up a super simple level just to test this issue.

I wonder if something changed 5.0 in how it handles passing in world/component space coords.

---

<div class="post-metadata">

**Author:** ![Dejan33](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dejan33/32/1194514_2.png) [@Dejan33](https://forums.unrealengine.com/u/Dejan33)\
**Post date:** [April 16, 2022, 11:36pm UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/7 "2022-04-16T23:36:34Z")

</div>

For my project 4.27.2 instanced static mesh collisions worked as expected. Converted to 5.0 and collisions detection work , but does not return proper index of the instance hit (or overlapping). Collision detection for instances might be broken or different approach is needed. Couldn’t find anything in the documentation for HISM.

---

<div class="post-metadata">

**Author:** ![Ferolynx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ferolynx](https://forums.unrealengine.com/u/Ferolynx)\
**Post date:** [April 17, 2022, 7:25am UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/8 "2022-04-17T07:25:36Z")

</div>

Sounds like exactly the same thing I’ve experienced @Dejan33 , as I explored further I noticed other HISM objects I have behaving oddly when it came to instance retrieval. I reported this as a bug, and in the mean time I will see if anything obvious stands out to me in the source.

---

<div class="post-metadata">

**Author:** ![Ferolynx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ferolynx](https://forums.unrealengine.com/u/Ferolynx)\
**Post date:** [April 17, 2022, 8:28am UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/9 "2022-04-17T08:28:13Z")

</div>

I checked the history on the HISM and it looks like between 4.27 and 5.0 there has been some fixes around transformations introduced. I reverted those commits and I now have it working closer to how it was before. Unfortunately I think it’s tangled with some rendering code so now I have foliage disappearing and reappearing based on my camera position, will continue to look into it!

---

<div class="post-metadata">

**Author:** ![Ferolynx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ferolynx](https://forums.unrealengine.com/u/Ferolynx)\
**Post date:** [April 17, 2022, 11:09am UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/10 "2022-04-17T11:09:28Z")

</div>

Ok I fixed it for my specific case. I observed the following…

UE5.0 introduced a variable on `InstancedFoliage.cpp` called `bUseTranslatedInstanceSpace` - From what I loosely understand, this aims to solve foliage precision in large worlds due to the use of floating points. The logic takes the first instance position and uses that as an origin space for all other foliage to calculate from.

The problem I believe is that this value is used when building the foliage tree, but not taken into consideration in both the GetOverlappingSphereCount or GetOverlappingBoxCount functions.

As for why I was experiencing this only after the first case, I think my foliage still had data stored from UE4.27, then when I removed instances it rebuilt the tree, causing the bug to be introduced. I also noticed that if I painted in the editor, the bug would occur on the first instance too.

So to fix this, as my worlds aren’t very latge - I put `bUseTranslatedInstanceSpace` to `false` instead which means the positions would always be based on 0, 0, 0 space. What I then had to do was make small edits to my foliage so the data was regenerated to whatever the UE5 required. I suspect that this might also be fixed if I rework the logic in the overlap functions to use this new variable.

---

<div class="post-metadata">

**Author:** ![Countsie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/countsie/32/1194632_2.png) [@Countsie](https://forums.unrealengine.com/u/Countsie)\
**Post date:** [April 18, 2022, 12:45am UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/11 "2022-04-18T00:45:41Z")

</div>

Good find. Thanks for the info 🙂

---

<div class="post-metadata">

**Author:** ![Kettenotter](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kettenotter/32/620822_2.png) [@Kettenotter](https://forums.unrealengine.com/u/Kettenotter)\
**Post date:** [June 26, 2022, 2:26pm UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/12 "2022-06-26T14:26:48Z")

</div>

Have the same problem and someone already reported it.  
If you want to get it fixed asap you can upvote it here:

> **[The Unreal Engine Issues and Bug Tracker](https://issues.unrealengine.com/issue/UE-149109)**
>
> Welcome to the Unreal Engine Issue and Bug Tracker. You can check the status of an issue and search for existing bugs. See latest bug fixes too.

or if someone is good at c++, there is always the option to make a pull request. And thanks for sharing your finds 🙂 at least now I know why it doesn’t work.

---

<div class="post-metadata">

**Author:** ![Slavq](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Slavq](https://forums.unrealengine.com/u/Slavq)\
**Post date:** [June 26, 2022, 7:46pm UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/13 "2022-06-26T19:46:58Z")

</div>

Hey, thanks, it was me, it seems like a new issue in 5.0, more info:

> [@Instance overlap functions for foliage don't work in UE 5.0 \[reported\]](https://forums.unrealengine.com/t/instance-overlap-functions-for-foliage-dont-work-in-ue-5-0-reported/518664):
>
> If someone has issues with it, I’ve already reported it with a simple repro project. Case # 00424950: Instance overlap functions don’t work anymore for foliage (regression from UE5 EA) Basically, functions like [GetInstancesOverlappingSphere](https://docs.unrealengine.com/4.26/en-US/BlueprintAPI/Components/InstancedStaticMesh/GetInstancesOverlappingSphere/) don’t work when called on Foliage ISM component, but work correctly when called on regular ISM or HISM components. Edit: Link to the simple repro project: [Box](https://app.box.com/s/pmpjs84wi1xq5cfxklf8lm25ye2yvzva) When calling HISM function, it prints the correct amount (14). If calling the Foliage ISM functi…

---

<div class="post-metadata">

**Author:** ![Kettenotter](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kettenotter/32/620822_2.png) [@Kettenotter](https://forums.unrealengine.com/u/Kettenotter)\
**Post date:** [June 27, 2022, 2:07am UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/14 "2022-06-27T02:07:16Z")

</div>

I pulled the current main branch and was delighted to see that the bug was gone. (In my testings) I will just have to ignore the newly added graphic glitches. 😄

![UnrealEditor_28](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/1/e/d1e08fba92ef88460afb5219988d39345d0f7743.gif)

---

<div class="post-metadata">

**Author:** ![Slavq](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Slavq](https://forums.unrealengine.com/u/Slavq)\
**Post date:** [June 27, 2022, 10:40am UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/15 "2022-06-27T10:40:16Z")

</div>

That’s great! So looks like they’ll succeed with the 5.1 target fix 🙂

---

<div class="post-metadata">

**Author:** ![Piece\_of\_Sheet](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Piece\_of\_Sheet](https://forums.unrealengine.com/u/Piece_of_Sheet)\
**Post date:** [May 6, 2025, 2:12am UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/16 "2025-05-06T02:12:20Z")

</div>

Looks like this function has broken again in 5.5, along with other issues with HISM that were introduced in 5.5. If you are having this issue on 5.5, my suggestion would be to consider switching to regular ISM and ditch HISM until a hotfix or hopefully a fix in 5.6.

---

<div class="post-metadata">

**Author:** ![sukovf](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sukovf/32/1008648_2.png) [@sukovf](https://forums.unrealengine.com/u/sukovf)\
**Post date:** [June 5, 2025, 4:52pm UTC](https://forums.unrealengine.com/t/get-instances-overlapping-box-sphere-not-working-as-expected-in-ue-5-0/530779/18 "2025-06-05T16:52:22Z")

</div>

It’s still broken in 5.6. I’m getting an empty array for the exact same setup as I’ve had i 5.3 where it worked just fine.
