# Trace ignores HISM Components?

**URL:** <https://forums.unrealengine.com/t/trace-ignores-hism-components/468383>\
**Category:** World Creation\
**Tags:** Trace, debug-trace, unreal-engine, collision-responses, bug-report, question\
**Created:** [July 19, 2020, 9:01pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383 "2020-07-19T21:01:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [July 19, 2020, 9:01pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/1 "2020-07-19T21:01:51Z")

</div>

I have a bp that can spawn many actors in, it for loops through all hism components and if there are more then 10 it will get a random one and delete everything around it, but my trace absolutely refuses to acknowledge the existence of theses actors. Everything collision is good and the trace responses are all correct. Any help appreciated.

 ![307576-traceshitstillbroken.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/5/3/9539b828615c02a114ae312d89de08d0992a35d2.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 19, 2020, 9:11pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/2 "2020-07-19T21:11:09Z")

</div>

Can you confirm that the array spat out by the _Multi Sphere Trace_ node contains multiple elements? Or is it completely empty?

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [July 19, 2020, 9:51pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/3 "2020-07-19T21:51:33Z")

</div>

A string confirms it is picking them up. For some reason they aren’t getting removed though.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 20, 2020, 6:56am UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/4 "2020-07-20T06:56:27Z")

</div>

> A string confirms it is picking them  
> up.

So the trace is _not_ ignoring them like the title suggests, right? It does pick them up but they’re not being removed? Can you confirm that?

How many instances are there in the component? Are we talking 100 or 100000?

Providing the _Multi Sphere Trace_ array does, indeed, contain what you think it does, I’d attribute this issue to something else. I believe that the instances _are_ being removed but without you noticing. You can count them before and after the operation.

* * *

Essentially, whenever you remove an instance, all indexes are shuffled. The next index in that loop is not assigned to the instance you expect.

This is easy to fix: instead of removing the instances one by one, add the indexes to an additional int array. When that loop Completes, remove them like so:

 ![307601-annotation-2020-07-20-075426.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/e/4/1e42196b008a6ff10a6b79982fe149c17c372acb.jpeg)

Ignore the sets. Then 0 identifies what needs to be removed, Then 1 removes all instances in one go so the indexes are not shuffled.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 20, 2020, 4:23pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/5 "2020-07-20T16:23:11Z")

</div>

Unfortunately that’s not the case here. You’re simply reverse iterating through the array, removing an instance will still rejiggle indexes - have a look:

[![Image from Gyazo](https://i.gyazo.com/6be8a8e6a575f3ce2195415beb77c0ba.gif)](https://gyazo.com/6be8a8e6a575f3ce2195415beb77c0ba)

better quality: [https://i.gyazo.com/6be8a8e6a575f3ce2195415beb77c0ba.mp4](https://i.gyazo.com/6be8a8e6a575f3ce2195415beb77c0ba.mp4)

I’m removing 1 per second. Notice how some indexes jump around. Even if you remove just 1, things shift around.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 20, 2020, 4:35pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/6 "2020-07-20T16:35:59Z")

</div>

In the animation above, on the very right hand side, you can see 92 and 93 turning into 5 & 11. When I remove the 8th & 9th element, there can be no index 92 or 93 anymore. So these 2 get reassigned whatever lower index is available due to removal of other instances.

* * *

If I start removing indexes, it all shrinks:

 ![307638-shrink.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/2/a/e2ac2fd53694a5adacbfcdbd8c04b6248741f994.jpeg)

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [July 20, 2020, 6:48pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/7 "2020-07-20T18:48:10Z")

</div>

I was under the impression my reverse for loop would iterate through reverse so the ints being shuffled wouldn’t effect it?

 ![307637-stilltracefucked.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/2/0/0201401df1eacc68d8af484b4ac93aa97029db96.png)

The trace hits the first one and then seems to stop, but it won’t seem to remove all that are hit, just some.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 20, 2020, 7:44pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/8 "2020-07-20T19:44:40Z")

</div>

You need to remove _the entire hit array_ at once as shown above - take a closer look. Removing them one by one will not work - explained why below.

In your example, you’re still doing the same thing.

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [July 21, 2020, 3:54pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/9 "2020-07-21T15:54:43Z")

</div>

I don’t think that’s gonna work that way, their are multiple different actors that need to be removed. I’m trying to do it by tag since it will work across multiple different hism components but adding them to a set and then doing remove instances still does nothing.

Maybe because the array is just ints? Shouldn’t I be storing the instances that are hit, not ints?

I’ve never used sets before… I can’t figure out how I actually add the ones that need removed to the set. Integer isn’t compatible with set of integers and I have no idea how to add the ones that are getting hit to this set.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 21, 2020, 4:31pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/10 "2020-07-21T16:31:24Z")

</div>

> Maybe because the array is just ints?  
> Shouldn’t I be storing the instances  
> that are hit, not ints?

You should be storing instances’ indexes - they’re ints. Essentially, if you want to remove a bunch of instances from a HISM by index, you need to remove all indexes in _one_ go, via the Remove Indexes (plural) node. _Never_ in a loop.

* * *

You do not need sets - not for what is demonstrated above at least. I use them as the procedural generation in my project is somewhat involved and I need to efficiently operate on a large numbers of elements without worrying about iterating over the same indexes again.

> I’ve never used sets before

You probably have, you mastered them somewhere in primary school. It’s usually about [fruit](https://docs.unrealengine.com/en-US/Engine/Blueprints/UserGuide/Sets/index.html), shapes, animals and whatnot:

> **[Set (mathematics)](https://en.wikipedia.org/wiki/Set_(mathematics))**
>
> A set is the mathematical model for a collection of different things; a set contains elements or members, which can be mathematical objects of any kind: numbers, symbols, points in space, lines, other geometrical shapes, variables, or even other sets. The set with no element is the empty set; a set with a single element is a singleton. A set may have a finite number of elements or be an infinite set. 
> Sets are uniquely characterized by their elements; this means that two sets that have precise...

Since HISMs’ instances always have unique numbers, sets make perfect sense here. If you want to, lets say, drop 3 bombs on the cubes below and remove everything the explosion radius hits, you’d combine 3 sets. Unlike an array, a set of 3 overlapping results would produce the precise number of uniquely indexed elements which you can later on remove with _Remove Indexes_ - all in a single BP execution, and without giving the indexes a chance to reshuffle.

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [July 21, 2020, 4:45pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/11 "2020-07-21T16:45:32Z")

</div>

> Since HISMs’ instances always have unique numbers

Is that gonna work across multiple hism components though? Say I have 3 or so and They can spawn in clusters and I want to remove any hism instances that are hit by a sphere trace. They all share the same tag so I figured a multi sphere with a tag loop would be enough.

 ![307735-84yearslater.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/1/6/c1672940766d75d65caf98910f1469458bce6b89.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 21, 2020, 4:56pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/12 "2020-07-21T16:56:22Z")

</div>

No, you’d need to perform one removal for each component.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 21, 2020, 5:09pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/13 "2020-07-21T17:09:06Z")

</div>

But this would just give you a single index. The trace does not really work if you want to hit more than one. You’d need need use this:

 ![307742-annotation-2020-07-21-180737.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/c/f/acf49ed7a802c0883c4d9d9f81f05d8b2189bada.jpeg)

When you hit the first instance, place the above at the instance’s location and it gives you everything around it.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 21, 2020, 5:16pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/14 "2020-07-21T17:16:04Z")

</div>

edit: I’ll try to come up with a better example if I find some time.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 21, 2020, 5:17pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/15 "2020-07-21T17:17:15Z")

</div>

Do note that sphere trace will stop if it encounters a blocking hit. So the above should be done on a separate, dedicated collision channel ideally.

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [July 21, 2020, 5:45pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/16 "2020-07-21T17:45:03Z")

</div>

![307739-fuckue4.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/0/1/20158c665ec0713e7acf4cb6ea188f98f4d098ee.jpeg)

This is the setup I’m attempting to use, it should loop through every component, but same problem, either nothing is getting removed or it’s maybe 1 instance in every loop.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 21, 2020, 8:46pm UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/17 "2020-07-21T20:46:43Z")

</div>

> This is the setup I’m attempting to  
> use, it should loop through every  
> component, but same problem, either  
> nothing is getting removed or it’s  
> maybe 1 instance in every loop.

Explained above (and several other places in the thread) why this wouldn’t work. Attached a working example in the answer.

Sorry, can’t do more for you.

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [July 22, 2020, 4:13am UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/18 "2020-07-22T04:13:47Z")

</div>

I wrote that out long before you posted your final few comments, I’m busy now but I can try the new setups tomorrow morning and I’ll update this post tor reflect it.

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [July 22, 2020, 6:04am UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/19 "2020-07-22T06:04:02Z")

</div>

![307797-traceborken.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/a/2/0a2fecc160cdcb0b1ebea8c17b224749ea29d04a.jpeg)

No dice…

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 22, 2020, 6:18am UTC](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383/20 "2020-07-22T06:18:03Z")

</div>

Apologies, working on many things at a time. I often fail to keep track of them all well enough.

[Next page](https://forums.unrealengine.com/t/trace-ignores-hism-components/468383.md?page=2)
