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!
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.
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:
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 …
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 …
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.
Sorry, my bad. Had a bit more time to look at this. It doesn’t work because even though the widget is remove, it still exist and the variable is valid.
Visibility works much better. Put this on begin play: