When I run a cooked version of my project (DebugGame or packaged), I’ve noticed that my widgets don’t destroy themselves properly. When I go between levels, sometimes widget persists and is still present despite destroying it on EndPlay.
After adding a Print node in my BeginPlay event, I noticed that HUD blueprint would sometimes fire BeginPlay event twice. This must be causing widget to stop destroying correctly, most likely overwriting first widget created with another widget created on second event call.
I could probably just use a DoOnce node, but I don’t really feel like adding a DoOnce every time I want to make a new HUD. I saw a suggestion somewhere that UE4 sometimes duplicates blueprints when you rename/move them, and I found some duplicates; but they weren’t duplicates of blueprint in question and it didn’t solve issue.
I should add that this never happens in-editor, just to be clear. Only happens in cooked builds.
I haven’t been able to reproduce this yet. Where are you creating widget? Can you reproduce this in a new project, or only your current project? If you can put together a small test project with which this occurs and upload it somewhere, I can take a look to see what might be causing this. Otherwise, a detailed step-by-step guide to reproducing it would be very helpful. Thanks!
When you go between levels, make sure you destroy widget first, and load next level only after that.
I’m trying to log all my BeginPlay calls to UE4_LOG but it’s being inconsistent, I’ll keep trying.
I got this once though:
[2015.03.04-09.36.03:298][ 38]LogTemp:Warning: ATownHUD::BeginPlay
[2015.03.04-09.36.03:299][ 38]LogTemp:Warning: AHUDBase::BeginPlay
[2015.03.04-09.36.03:343][ 38]LogTemp:Warning: AHUDBase::BeginPlay
Will post again when I find something else useful.
I fixed my problem! What was happening was I was calling OpenLevel multiple times. way this happened was that I couldn’t call OpenLevel straight away, because I wanted to render a loading screen first. To do this, I had to defer call to OpenLevel until end of next ReceiveDrawHUD call.
My mistake was that I assumed that OpenLevel would only be called once, as I thought it would almost immediately destroy level and load up a new one.
In short: Adding a DoOnce node after IsTeleportTriggered branch at end of my ReceiveDrawHUD event before calling OpenLevel fixed it.
Is it true that a function call to
OpenLevel will trigger event
BeginPlay within level’s blueprint?