# BreakHitResult Branching (Interactive Crosshair)

**URL:** <https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668>\
**Category:** UI\
**Tags:** Raycast, crosshair, interactive-objects, unreal-engine, door, question\
**Created:** [March 20, 2020, 11:58am UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668 "2020-03-20T11:58:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rocotos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rocotos](https://forums.unrealengine.com/u/Rocotos)\
**Post date:** [March 20, 2020, 11:58am UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/1 "2020-03-20T11:58:47Z")

</div>

Hello there!

While learning the basics of blueprints, I got stuck with one strange thing. What I’m trying to do is to change the crosshair image when the player gets close to an interactable object (door, in particular). I use **LineTraceByChannel** method, that works perfectly fine with the door animation. So I decided to copy-paste it for a new task.

But it works only partially: new crosshair appears when I am near the door, but then remains and do not disappear. I understand why. There’s no branching after **LineTraceByChannel** node and its **EXEC** pin is connected directly to the custom made **Crosshair\_change** event. But… how can I branch it? The **HitActor** pin can only be connected directly to a target, as it is **Actor Object Reference**. And the **Branch** node does not work with that.

Is there a way to branch **HitActor** pin to tell the script that when there is no raycasting interaction with the door, the crosshair image should not be printed? I tried to find some other ways of solving this puzzle, including an entirely different method of working with crosshair images, but found nothing.

It’s important to mention: I am new to programming and blueprint logics, so to me it is still very hard to come to solutions, that may seem obvious. My apologies for such questions. Thanks!

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/6/1/8613887bcd9a6cdd270bf9065e1cd9cb53a771ba.png)

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/2/6/f26bc9a4f8fd584415f918182d452ab3f543bf79.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 20, 2020, 12:29pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/2 "2020-03-20T12:29:49Z")

</div>

I’m assuming your interactable objects have a BP interface? If not that’s the way to do it.

Then, when your trace hits something, you can check ‘does it implement the interace’? If it does, change the crosshair otherwise change it back. Here’s my trace:

 ![298135-trace.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/7/a/97a575843b8828192ba82e4179b3071eae2abd7c.jpeg)

( the line trace macro is just what you have here basically )

The crucial thing is the ‘does implement interface’ node.

---

<div class="post-metadata">

**Author:** ![Rocotos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rocotos](https://forums.unrealengine.com/u/Rocotos)\
**Post date:** [March 20, 2020, 1:02pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/3 "2020-03-20T13:02:49Z")

</div>

Probably, I did something wrong, because even with **does implement interface** node the HUD widget image appears, but do not disappear after going away from interactable object.

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/1/6/5167754057adbf583f40db4d9bf398a14f8e24fc.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 20, 2020, 1:06pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/4 "2020-03-20T13:06:39Z")

</div>

You have to put the code to turn off the widget on the false branch of the IF 🙂

---

<div class="post-metadata">

**Author:** ![Rocotos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rocotos](https://forums.unrealengine.com/u/Rocotos)\
**Post date:** [March 20, 2020, 1:14pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/5 "2020-03-20T13:14:45Z")

</div>

Oh god, I think I finally worked it out! Thanks a lot mate, that was really helpful and on time!

---

<div class="post-metadata">

**Author:** ![Daedalvs\_Design](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Daedalvs\_Design](https://forums.unrealengine.com/u/Daedalvs_Design)\
**Post date:** [July 31, 2020, 2:57am UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/6 "2020-07-31T02:57:46Z")

</div>

Hey ! I wanted to know if your interactive crosshair work correctly ?  
If yes, would it be possible to have an explanation or screenshot of your blueprint ?  
I keep searching and trying to understand, I can’t make an interactive crosshair …

Thank you ! 🙂

---

<div class="post-metadata">

**Author:** ![Daedalvs\_Design](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Daedalvs\_Design](https://forums.unrealengine.com/u/Daedalvs_Design)\
**Post date:** [July 31, 2020, 2:58am UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/7 "2020-07-31T02:58:03Z")

</div>

Hey ! I wanted to know if your interactive crosshair work correctly ?  
If yes, would it be possible to have an explanation or screenshot of your blueprint ?  
I keep searching and trying to understand, I can’t make an interactive crosshair …

Thank you ! 🙂

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 31, 2020, 7:23am UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/8 "2020-07-31T07:23:24Z")

</div>

Basically, it’s composed of two things:

1. A widget that zooms in and out

2. A line trace from the camera, that when there’s a hit, zooms in. And when there’s no hit, zooms out.

---

<div class="post-metadata">

**Author:** ![Daedalvs\_Design](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Daedalvs\_Design](https://forums.unrealengine.com/u/Daedalvs_Design)\
**Post date:** [July 31, 2020, 12:24pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/9 "2020-07-31T12:24:05Z")

</div>

Thanks for your answer !

I was searching to replace my actual crosshair with another while being over an interactive object. I already have my line trace. But my problem is to switch from a crosshair to another.

 ![308743-crosshair1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/4/0/e409958875ef0285f4de5150e292196331df54dd.jpeg)

 ![308744-crosshair2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/a/0/3a050ba1ddc28b478c93125db2e7470553fc8e18.jpeg)

In my widget there the crosshair when I’m over an interactive object, and in my HUD, there’s the normal crosshair

PS : I’m still a noob with blueprint, I’m trying to learn and understand.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 31, 2020, 12:37pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/10 "2020-07-31T12:37:21Z")

</div>

You have to do all the crosshair stuff in one place.

When the object is interactable draw crosshair A, otherwise draw crosshair B.

This is all I have:

 ![308747-ch.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/f/a/ffab3a0aad4ff2fb694ab1bf327a766ffb575979.jpeg)

So if it’s a blocking hit do one ch, otherwise do the other…

( I don’t return a hit from the function, unless the object implements an interface.

---

<div class="post-metadata">

**Author:** ![Daedalvs\_Design](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Daedalvs\_Design](https://forums.unrealengine.com/u/Daedalvs_Design)\
**Post date:** [July 31, 2020, 2:17pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/11 "2020-07-31T14:17:14Z")

</div>

I did it, it work but same as above, the crosshair is not replaced but just add to the other one and I can’t use the “remove from parent”

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 31, 2020, 3:06pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/12 "2020-07-31T15:06:23Z")

</div>

Are you adding the widget right after the line trace code?

Then you have a reference to the widget and can remove it before adding the other one.

Sorry, I don’t know your setup…

---

<div class="post-metadata">

**Author:** ![Daedalvs\_Design](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Daedalvs\_Design](https://forums.unrealengine.com/u/Daedalvs_Design)\
**Post date:** [July 31, 2020, 3:34pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/13 "2020-07-31T15:34:07Z")

</div>

Here is my setup, I hope it help you. Thank you very much for taking your time to help me, really.

 ![308737-crosshair1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/c/c/8cc65a95211fa8816a05ea0e30eb74e1c9e8ae3c.jpeg)

 ![308738-crosshair2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/e/2/7e29bdcdfce33e1489b1fa68fb921fc7fd25d3f1.jpeg)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 31, 2020, 4:32pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/14 "2020-07-31T16:32:14Z")

</div>

So, put those references coming out of the widgets into variables:

 ![308773-var.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/3/6/43692a86551b6cd6fe04ef021b8a5b75222aeb41.jpeg)

and when you do one, you remove the other:

 ![308774-rm.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/0/a/10a8da4529a22295603ee5f113d6aed23a332583.jpeg)

Tell me if you get stuck…

---

<div class="post-metadata">

**Author:** ![Daedalvs\_Design](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Daedalvs\_Design](https://forums.unrealengine.com/u/Daedalvs_Design)\
**Post date:** [July 31, 2020, 5:05pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/15 "2020-07-31T17:05:45Z")

</div>

It still do the same, the second crosshair appear but the first one doesn’t disappear (and the second one too when I’m not on an interactive object)

 ![308777-crosshqire8reove8pqrent.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/2/e/a2ea50c2b7699c37c044f5dae45f469b206a2fab.jpeg)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 31, 2020, 5:56pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/16 "2020-07-31T17:56:55Z")

</div>

You’re nearly there, but you’ve got the logic wrong. When the item is useable you need one ch, otherwise the other ch.

At the moment your code says ‘if item it useable, swap ch’

See what I mean?

Ditch that swap concept. Just do one or the other.

Like this:

 ![308802-together.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/8/2/8825fd3e94bbd0d6c96ee7fa21b02ec552169c20.jpeg)

( except normal and select the other way around ).

---

<div class="post-metadata">

**Author:** ![Daedalvs\_Design](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Daedalvs\_Design](https://forums.unrealengine.com/u/Daedalvs_Design)\
**Post date:** [July 31, 2020, 6:34pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/17 "2020-07-31T18:34:12Z")

</div>

I will be a stupid question but … what do you mean by “ch” ?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 31, 2020, 6:37pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/18 "2020-07-31T18:37:21Z")

</div>

Crosshair 🙂

---

<div class="post-metadata">

**Author:** ![Daedalvs\_Design](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Daedalvs\_Design](https://forums.unrealengine.com/u/Daedalvs_Design)\
**Post date:** [July 31, 2020, 6:47pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/19 "2020-07-31T18:47:41Z")

</div>

If you meant like this, I already tried but it doesn’t work, I always have the message you see under that appear

 ![308804-desperation.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/f/4/2f40cb8fdc08ad5ebce41f1b2692ede5d46beea5.jpeg)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 31, 2020, 6:53pm UTC](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668/20 "2020-07-31T18:53:28Z")

</div>

Ok, does it work apart from the message?

[Next page](https://forums.unrealengine.com/t/breakhitresult-branching-interactive-crosshair/462668.md?page=2)
