# Hit Result=True even when Visibilty=False

**URL:** <https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790>\
**Category:** Blueprint\
**Tags:** line-trace, cursor, visibility, trace-channels, unreal-engine, Blueprint\
**Created:** [September 23, 2024, 8:58am UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790 "2024-09-23T08:58:44Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Virtuality](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/virtuality/32/1140891_2.png) [@Virtuality](https://forums.unrealengine.com/u/Virtuality)\
**Post date:** [September 23, 2024, 8:58am UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/1 "2024-09-23T08:58:44Z")

</div>

In Unreal Engine 5.4.3, I’m getting this strange behavior:

1. Set a Static Mesh with “Visible=False” and/or “Hidden In Game=True”
2. Do a “Get Hit Result Under Cursor By Channel” (with Trace Channel=Visibility)

I get hit results on the Mesh. Only if I disable the Visibility Channel (set to Ignore) the Trace Channel I stop getting hit results.

Is this expected behavior?

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/f/7/5f75ec1e2bd3bac51ede9e185a84d1bca6781e6b.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:** [September 23, 2024, 9:02am UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/2 "2024-09-23T09:02:39Z")

</div>

> Is this expected behavior?

Yes. Visibility is a trace channel - it has nothing to do with:

> Set a Static Mesh with “Visible=False” and/or “Hidden In Game=True”

The above controls whether the asset needs to be rendered, not whether it responds to tracing / collision.

---

<div class="post-metadata">

**Author:** ![Virtuality](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/virtuality/32/1140891_2.png) [@Virtuality](https://forums.unrealengine.com/u/Virtuality)\
**Post date:** [September 23, 2024, 9:12am UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/3 "2024-09-23T09:12:45Z")

</div>

Right, ok.

So is there any direct way to trace against objects that are actually visible on-screen? Or is the solution to toggle the trace channel together with the visibility in BP?

---

<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:** [September 23, 2024, 9:14am UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/4 "2024-09-23T09:14:30Z")

</div>

> [@Virtuality](#):
>
> So is there any direct way to trace against objects that are actually visible on-screen?

You could check first:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/0/f/90f2df0fd75908304827bad2a32871e6a464a258.png)

Or query the object’s `Visibility` / `Hidden` flags.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/5/4/954761aa360d96bdc2df1fd7c4ee2900c2b96d69.png)

But the above will not work if the object is outside of the camera frustum, ofc, but the `Recently Rendered` handles that.

* * *

> Or is the solution to toggle the trace channel together with the visibility in BP?

That’d work, too. Note we can add custom channels / object types which helps achieving the sometimes necessary granularity of who can interact with whom.

---

<div class="post-metadata">

**Author:** ![Virtuality](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/virtuality/32/1140891_2.png) [@Virtuality](https://forums.unrealengine.com/u/Virtuality)\
**Post date:** [September 23, 2024, 9:25am UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/5 "2024-09-23T09:25:51Z")

</div>

Thank you.

Those solutions would work to check if the result is valid or not, but would make the “Get Hit Result Under Cursor” useless… I’d have to trace again - ignoring the invalid hits - until hitting something that meet the criteria (of being recently rendered).

---

<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:** [September 23, 2024, 9:30am UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/6 "2024-09-23T09:30:36Z")

</div>

> [@Virtuality](#):
>
> “Get Hit Result Under Cursor” useless… I’d have to trace again - ignoring the invalid hits - until hitting something that meet the criteria (of being recently rendered).

Pretty much, yeah - `Get Hit` **is** tracing (from the camera towards the cursor) but _automated_ and set up in the player controller:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/a/3/0a39a3c384c4a3baeea3ad4bb8048ca031d38bc7.png)

Do not trust the _clicked_ part, it’s lying.

* * *

Perhaps you could share what the overarching goal is - there may exist a neat solution; there may be none besides laborious flag checking and double traces.

I am guessing you want to ignore traces against objects that are not being rendered. If so, perhaps the objects themselves can periodically check whether they are being rendered and flip their tracing channels to `Ignore`. Feasible?

---

<div class="post-metadata">

**Author:** ![Virtuality](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/virtuality/32/1140891_2.png) [@Virtuality](https://forums.unrealengine.com/u/Virtuality)\
**Post date:** [September 23, 2024, 9:36am UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/7 "2024-09-23T09:36:10Z")

</div>

> [@Everynone](#):
>
> I am guessing you want to ignore traces against objects that are not being rendered.

Pretty much, yes. I’m using a Variant Manager to show/hide objects and I want the Trace to return only objects that are currently visible (so that I can “select” them and show details about the selection). Hidden objects should be ignored for this purpose.

---

<div class="post-metadata">

**Author:** ![Virtuality](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/virtuality/32/1140891_2.png) [@Virtuality](https://forums.unrealengine.com/u/Virtuality)\
**Post date:** [September 23, 2024, 9:38am UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/8 "2024-09-23T09:38:47Z")

</div>

So now I’m running this as a temporary solution:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/7/7/c77c3cc65b176352a6dbebca52bb557b745d7ea0.png)

It works, but has to iterate over all meshes each time I activate a new variant. Trying to avoid time-consuming loops like this.

---

<div class="post-metadata">

**Author:** ![Virtuality](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/virtuality/32/1140891_2.png) [@Virtuality](https://forums.unrealengine.com/u/Virtuality)\
**Post date:** [September 23, 2024, 9:44am UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/9 "2024-09-23T09:44:28Z")

</div>

I don’t know… It just feels that there should be an easy and obvious solution to just trace against what you can currently see on the screen. Like, if it’s rendered that it should respond to my trace. But I guess that just doesn’t exist 🙂

---

<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:** [September 23, 2024, 9:46am UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/10 "2024-09-23T09:46:48Z")

</div>

> Variant Manager

Never worked with it so my understanding of the internal workings is next to none.

However, since this is a singular event (rather than spamming this on Tick) that’s probably fine unless you iterate over thousands of elements. On the other hand, assuming the manager flips some assets around, isn’t there a delegate you can hook up to? What actually happens when:

> using a Variant Manager to show/hide objects

Isn’t there a return of some kind that would allow you to effect the tracing channels when variants change? Something like this pseudo-dispatcher:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/4/5/d45197bc48231286edee7af40be65232e5533dbd.png)

This may be a silly question - I simply do not know how it works.

---

<div class="post-metadata">

**Author:** ![Virtuality](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/virtuality/32/1140891_2.png) [@Virtuality](https://forums.unrealengine.com/u/Virtuality)\
**Post date:** [September 23, 2024, 9:54am UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/11 "2024-09-23T09:54:13Z")

</div>

> [@Everynone](#):
>
> Isn’t there a return of some kind that would allow you to effect the tracing channels when variants change?

It’s a loop in C++ that I can’t hook in to easily. The Variant Manager flips parameters of all objects that are part of the Variant Set (which you can manually set). Issue is that not all parameters can be set this way - so for example I can set “Can Character Step Up On”, but I can’t set “Collision Presets”. Seems a bit random.

Anyway, I can execute a general loop after (which is what I’m doing as per above). I could narrow down the loop with a Static Mesh Tag or something.

---

<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:** [September 23, 2024, 9:59am UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/12 "2024-09-23T09:59:33Z")

</div>

> [@Virtuality](#):
>
> The Variant Manager flips parameters of all objects that are part of the Variant Set

I’ve launched the template:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/2/f/e2f0e795df396c8a5d63dde3dec92fbb67dd1c27.png)

Could you get cheeky and **move** the asset away where it cannot be interacted with?

* * *

You may need to wait for someone who knows the intricacies of how the manager works. I may need to tap out on this one, sadly.

---

<div class="post-metadata">

**Author:** ![Virtuality](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/virtuality/32/1140891_2.png) [@Virtuality](https://forums.unrealengine.com/u/Virtuality)\
**Post date:** [September 23, 2024, 10:14am UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/13 "2024-09-23T10:14:04Z")

</div>

> [@Everynone](#):
>
> Could you get cheeky and **move** the asset away where it cannot be interacted with?

Not a bad idea.. 💡

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [September 23, 2024, 8:38pm UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/14 "2024-09-23T20:38:33Z")

</div>

Sounds like a job for Collision Profiles or Custom Trace channel.

Really depends on how your triggering Hidden.

---

<div class="post-metadata">

**Author:** ![baobao4435](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/baobao4435/32/950790_2.png) [@baobao4435](https://forums.unrealengine.com/u/baobao4435)\
**Post date:** [September 23, 2024, 9:13pm UTC](https://forums.unrealengine.com/t/hit-result-true-even-when-visibilty-false/2033790/15 "2024-09-23T21:13:33Z")

</div>

an easiest way comes to my mind is to disable its collision when it gets setting to hidden.  
Use “set collision enabled” node.
