I’m still a little new here so forgive me if this is in fact not a bug and working as intended but I have reproduced an apparent bug. Simply put, the “Event Destroyed” event is fired once after the game is started from an “open level” event (So not at event begin play). Particularly if the event is called from a different level, if it is launched from the same level there is no issue and it does not fire.
Such an example and where I first saw it pop up would be from a main menu (in it’s own dummy level) opens a level, in which my death menu would pop up (Confirmed by putting a print string right after the event destroyed event).
For my project I didn’t need that event at all and just connected my death menu script to the rest of the death script problem solved.
Steps to reproduce are simple:
Create a new project with the 2d sidescroller template (no starter content needed).
Go to Content, 2DSidescrollerBP, and open the Blueprints folder, open the 2SideScrollerCharacter and anywhere in the event graph add the event destroyed event with a print string attached to it as described previously.
Go to Content, 2DSidescrollerBP, maps and crate a new level (we’ll call it level 1)
Open level 1 and inside it’s level blueprint at event begin play add the delay and then open level “2DSideScrollerExampleMap” (This way has the game mode already set with the player character already set up+gamemode, which is key to reproduce)
Maybe I misunderstood the node and everything is working fine, but I would expect the node to only fire when the actor has been explicitly destroyed. - Perhaps that happens behind the scene automatically during loading causing the confusion.
I would consider this behavior to be incorrect, although I’m not receiving the same behavior that you’re mentioning when following your steps. I created Level1 and Level2 as mentioned and here are their blueprints:
I added the beginplay one for Level1 after trying it a few times since there as no feedback that the new level had been added, but I never got anything from Event Destroyed in either case.
Could there be some other settings you have enabled that could be causing this to occur?
I made the mistake of assuming the reproduction steps would work (I did reproduce it on a totally separate project but not exactly as described) That was my mistake and I won’t make it again. Sorry for wasting your time with faulty reproduction steps. Here are new steps that should work and is exactly what I have done just now on a brand new template precisely as described.
Create a new project with the 2d sidescroller template (no starter content needed).
Go to Content, 2DSidescrollerBP, and open the Blueprints folder, open the 2SideScrollerCharacter and anywhere in the event graph add the event destroyed event with a print string attached to it as described previously.
Go to Content, 2DSidescrollerBP, maps and crate a new level (we’ll call it level 1)
Open level 1 and inside it’s level blueprint at event begin play add the delay and then open level “2DSideScrollerExampleMap” (This way has the game mode already set with the player character already set up+gamemode, which is key to reproduce)
Let me know if that works, Before doing it this way I found it under 2 separate conditions one in my game project with just my own content(own game mode, with the event destroyed placed within my player blueprint), and to verify it was a bug I opened a much older project that had starter content that I used previously (Which contained the default game mode, player, etc). Wrongfully that made me assume it would be reproduced right off the bat just in an empty scenario within both level blueprints. To reproduce I believe you must have the event destroyed event inside a character type blueprint, that is referenced by the active game mode. I did my due diligence this go around and followed my exact steps twice.
I just tested this on my partner’s rig and I can reproduce with the above steps. Hopefully you can too. Again I apologize for my crappy instructions in the original post I know those mistakes made by assumption can waste everyone’s time.
Thank you for the updated steps. These do reproduce the behavior you’re seeing but there is a huge difference between the two scenarios, namely playing the logic on the character instead of the map. Remember that the GameMode is set for the entire project inside of your Project Settings unless overridden in the World Settings for a map. This means that when creating a 2D Side Scroller Template project, the GameMode is automatically set to the 2D Side Scroller GameMode for all maps, including the newly created one.
This leads to the behavior. When you start the game in level1, the character is spawned since the GameMode is set to spawn this as the default character. When you run OpenLevel, the character, along with everything else in the level, is destroyed. This causes the Destroyed event to be called on what seems to be the new level but it’s happening so fast that you can’t see that it’s actually happening prior. You can test this by adding a BeginPlay print as well, as it will show up after the Destroyed one when the character is loaded in the new level. You can also tell from the log. You can see my outputs “BeginPlay” and “Destroyed”. The first BeginPlay is when PIE starts, and then it is followed up by Destroyed when OpenLevel is called. After the level loads, BeginPlay is shown again as the new level’s character has been loaded.
With the setup provided, this is expected to occur.
That makes sense, I didn’t have a game mode set up for my main menu dummy level so it used my project setting’s default game mode. Thanks for the detailed information explaining what was afoot.