No announcement yet.

Did Event Begin Play change in 4.15? Not firing with PIE

  • Filter
  • Time
  • Show
Clear All
new posts

    Did Event Begin Play change in 4.15? Not firing with PIE

    I have a custom Player Controller class, and a custom Pawn class, and a custom Game Mode class.
    My Game Mode is set as the default game mode.
    The Game Mode specifies the Pawn class and Player Controller class.

    This project was created as a plain (empty) blueprint project template, and I've just added these basic classes, as well as a new default map (single BSP floor and skybox) to play around in.

    When I hit "play" -- either in-editor, or in new window in editor (still PIE mode) the Event Begin Play event doesn't fire on my Player Controller nor my Pawn.
    I've tried with a breakpoint on the event itself, as well as a Print String right as the first action of the event; they do not fire.

    I also know that the player controller and pawn classes are being used.
    The PlayerController Tick event gets fired. And, in fact, complains, because my cached custom PlayerState variable is None, because I use Event Begin Play to get the PlayerState (I have configured a custom Player State class) and cast it to my custom type and stuff it in a variable.

    I have a strong feeling that this used to work in older versions? Or am I missing something?

    Click image for larger version

Name:	playercontroller-eventbeginplay.jpg
Views:	1
Size:	434.6 KB
ID:	1211640
    Last edited by jwatte; 02-20-2017, 02:35 AM.

    Some actors (Controller, GameMode but not Pawn) start ticking before BeginPlay - this is a default behaviour that can be overridden; all 3 start with Tick Enabled by default, too. Perhaps you could adjust it in the Class Defaults --> Actor Tick tab.

    While this could explain why you're seeing Accessed None when using Tick, I'm not so sure about BeginPlay not firing. I'm currently using 2 BeginPlays - 1 in GameMode and 1 in the Controller and both trigger correctly. Just added another one in the Pawn and it also behaves as expected. This is in 4.15.


      I found out what causes this.

      1) Start a new project as empty blueprint.
      2) Create BP_GameMode as gamemode
      3) Create BP_PlayerController as playercontroller, make it print in event begin play
      4) Configure the BP_PlayerController as the player controller in the gamemode
      5) Configure the BP_GameMode as the default game mode in project settings and build/save
      6) At this point, it will fire the event begin play
      7) Create BP_PlayerCameraManager as playercameramanager
      8) Assign BP_PlayerCameraManager as the camera manager for BP_PlayerController and build/save
      9) At this point, you will not see the event begin play fire

      And, here comes the super curious bit:

      10) Re-set the player camera manager back to None in BP_PlayerController
      11) Delete the BP_PlayerCameraManager class from the project
      12) Save/build
      13) It still doesn't get the begin play events

      It's like something in assigning a custom player camera manager permanently messes up the project. Which is ... I have a hard time explaining how that could even happen.


        Odd, indeed. I'm using a custom camera manager as well and never run into an issue like that, bit scared to follow 10-13 ;p
        Checked it with the default PlayerCameraManager, None and a Custom one and no issues so far - custom controller, pawn and game mode all fire their BeginPlays respectively.


          I think this may be for projects that are created new in 4.15, based on the blueprint templates.
          It should be fine (and only take 5 minutes) to try this from scratch with a new empty project.

          I even pulled the source from GitHub and stepped through the setup in Visual Studio, and while I can conform the on-screen behavior, I didn't find out why.
          The BeginPlay() gets called on all components, including the custom camera manager blueprint class.
          My best guess is that the camera manager blueprintization somehow is invalid and messes up the event dispatch mechanism within the project. Which is ... a pretty squishy guess :-(
          To get any further I'd have to dive deep into learning the internals of blueprint <-> C++ interop, which is not something I can do right now.

          I filed an AnswerHub bug, at least.


            I followed your steps, blank project, 4.15:

            3. nothing happens, as expected
            6. BeginPlay works as intended (controller)
            9. it works for me, BeginPlay in the controller fires a print string

            Click image for larger version

Name:	Untitled.png
Views:	1
Size:	35.7 KB
ID:	1123637

            13. After unbinding the custom CameraManager from the Controller (set to None, compile) and deleting the cam BP, the controller still fires its BeginPlay

            Sorry, but I could not reproduce the issue :|


              I'll see if it happens on my second computer.
              And, if it does, I'll see if ShadowPlay will actually record the whole thing.
              If it doesn't happen there, that would be another clue...


                Ha! I was not being as careful as I thought when reproducing the problem.
                When making the custom game mode, I also made a custom game state.
                It seems to be this custom game state that causes the problem.
                There are screen shots in the answerhub:


                  With help from the friendly helpers on AnswerHub, I've learned that mis-matching GameMode/GameModeBase with GameState/GameStateBase will cause event begin play to not fire.
                  So, that's what's going on here.
                  Now, for the next question: Why would this happen? Why are there even two different classes for this?

                  GameState blanks out the NotifyBeginPlay() whereas GameStateBase runs it:
                  void AGameStateBase::HandleBeginPlay()
                  	bReplicatedHasBegunPlay = true;
                  void AGameState::HandleBeginPlay()
                  	// Overridden to not do anything, the state machine tells world when to start