Branch node after line trace gives accessed none error on play stop

I’ve been trying for several days to solve this issue and I still can’t figure out despite how many videos and articles I read. I’m sure this is due to being a beginner. I’m working on a work related project (which is not exactly a game) for which the player walks around a large room with frames on the wall. When the user is in front of one of those frames, the cursor (what would normally be the crosshair in the FPS template) changes to another one, because then the player can click on it and there’s an overlay widget that takes the full screen. Then, the player clicks on the right button to close the full screen widget and return to the “game”.

The way I’m trying to achieve this is with a custom HUD that is selected in the world settings. In this HUD, there’s a line trace by channel node along with a break hit by result node. The exec out of the line trace node goes to a branch node. The “Out hit” goes to the “Break hit by result” node. Then, the “hit actor” output in this node goes out to an “Actor has tag” node, with the tag being “picframe”, which is a tag all the frames have (the frames are all blueprint actors). After that, the return value of this node goes out to the condition input of the branch node.

The last step is the true or false in the branch. If it’s true (meaning, if the actor blueprint has a “picframe” tag in it), then it goes to a “Draw texture” node, which draws a cursor. If the branch node condition is false (everything else that is not a picframe), then it goes to another draw texture node, which draws another cursor on screen.


This compiles fine every time. And, when I hit play, it works as expected. However, when I press Esc to stop the game preview, the message log shows with 200 messages all saying the same:

“Blueprint Runtime Error: “Accessed None trying to read property CallFunc_BreakHitResult_HitActor”. Blueprint: Custom_HUD Function: Execute Ubergraph Custom HUD Graph: EventGraph Node: Branch”

And the branch is the branch I show here which basically has the picframe tag condition and the true and false outputs.

So does anyone have any idea what am I doing wrong here? And why does it compile and save fine, but also plays fine and acts as expected, but gives me that error when stopping the preview?

Probably the Branch sometimes has no valid input because nothing was hit? Use another Branch node that has the ‘Return Value’ bool of the LineTrace node as an input. That bool tells you if there was a hit in the first place. Or use a Is Valid node for the Hit Actor. (Sorry, I am not at my PC for screenshots / double checking right now)

2 Likes

Yes so as @Pantoth says the problem is that the hit actor is returning null. So you need to put an isvalid test in like this

2 Likes

Thank you both for your replies. Unfortunately that doesn’t work. What that gives me when I preview is no cursor when I’m walking around, but it does give me the cursor that I set as the hover one.
This doesn’t give me the error anymore, but it doesn’t do what I need it to do.

Ah sorry I missed that you had a flow off the false - you need to connect that to the In Not Valid pin as well as where it is currently connected. So no actor gets the flow and an actor not tagged get the flow

OK, so if you mean like this:

With the “Is Not Valid” output going to the draw texture node that draws the regular cursor, and the “Is Valid” output going to a branch node that has the condition actor with “picframe” tag, then the true output goes out to the draw texture that has the hover icon.

So what happens in this case is that (I think) that when the line trace hits an actor with the picframe tag it shows the hover cursor (that works), but when it hits any component that is not tagged as picframe, it doesn’t draw a cursor. When it doesn’t hit anything, it shows the regular cursor. And, this doesn’t give me the error when I press escape.

The line trace is set to 500, so I think the behavior is basically that, line trace hits actor with picframe tag, it draws the texture with hover cursor. If line trace hits actor but is not tagged picframe, it draws nothing at all. If line trace doesn’t hit anything, then it draws the texture that has the regular cursor.

I have done so many combinations that I already forgot some of them. I even tried a node connected to the “Actors to ignore” and then adding a different tag to the actors that I didn’t want to include, but that didn’t work.

But one thing that may cause a problem in my case is that part of the level’s meshes are components in the level itself, and many others are inside a blueprint actor, because we’re just a few guys that started learning Unreal a couple of months ago, and maybe we haven’t done things in the most adequate way. So for example, I wanted to add, in the same way I have a condition node “Actor has tag”, another “Component has tag” node, which is basically the same as the actor one but for components. Problem is, if I drag the return value from it to the branch condition input, it disconnects the one that was coming from the “Actor has tag” node. Do you think it might be worth looking into that?

The last Branch node, where you check for the ‘picframe’ tag, needs a connection from False to the default cursor. (like the Is Not Valid route)

As for the Actor / Component thing: There may be many possible ways to solve this. To extend your Branching you can simply add the Component Has Tag right after the Actor Has Tag branch, connected to the False execution output. Or you check, if the Hit Actor is a Picture Frame Actor (if you have one actor specifically for that?)

You still need it to ALSO come of the original false on the original has tag branch as well
So VadID object (yes) then has it got the tag (YES - CHange) no Draw not.

Thanks a million guys, that finally worked. So in case anyone else has this same problem, here’s how it finally worked with the desired behavior and no error when I stopped playback:

(I know this will look really tiny, you probably have to click to open the full screenshot on a 27" monitor)

Glad you got it worked though.