Hit Result=True even when Visibilty=False

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

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.

1 Like

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?

You could check first:

Or query the object’s Visibility / Hidden flags.

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.

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).

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

image

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?

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.

So now I’m running this as a temporary solution:
image

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

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 :slight_smile:

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

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

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.

I’ve launched the template:

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.

1 Like

Not a bad idea… :bulb:

Thank you for your help!

1 Like

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

Really depends on how your triggering Hidden.

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