Download

Cast to HUD makes the game crash after a while?

Hey!

I have a problem with my Character blueprint.
In it, I have some nodes to check what the player is looking at. It looks like this: http://puu.sh/8cFDX.jpg

The problem is that after like 20-50 seconds, the game closes down with a “Runnable thread crashed” error in the log.
I have managed to pinpoint it to be caused by either of the “Cast to NewHUD”'s at the end.
Previously, I had both of those comment boxes (and other BP’s to check for) in separate functions, but the mere existence of those functions caused the game to not start at all (even if they weren’t hooked up to anything), while having the nodes out directly (or in a collapsed node), causes the game to crash after a while.
What’s up with that? Am I doing something stupid?
Also, is there a better way to check what the player is looking at?

Thanks! :slight_smile:

Edit: Might be worth mentioning that the crash only happens when running Launched/Packaged, not when playing in viewport.

I’m not entirely sure…

One thing i’d recommend is not trying to set some object on the hud class from the character blueprint.
Have it as some accessible value on the character, and have the hud retrieve and cast it.

Also while there is the success/fail branches of the cast node, i am unsure if relying on it like this is a good idea.
I mean this thing could be pulling up a collision with any type of actor, and the cast could complete, leading to you setting properties on an invalid object, potentially buggering up memory.

(Since the cast is ‘actor’ → ‘BP_ParentInteractible’ … as opposed to ‘BP_InheritedClassName’ → ‘BP_ParentInteractible’ which i would expect to succeed / fail correctly)

This may or may not be what is happening, i am unsure how safe the cast node is to be confident.

Thank you!
Having the value on the character worked :slight_smile:
I’ll make a “BP_InheritedClassName” thing too, just to be safe for the future.

Nothing you can do in Blueprints should ever crash though! If you could find a minimum reproduction case and post it on Answer Hub, that would be very helpful to us in tracking down and fixing that case.

I could not reproduce the crash with satisfactory results right now, however I managed to find another bug which I have posted here](Getting an object from character blueprint in HUD blueprint causes HUD to stop functioning - UE4 AnswerHub)