x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Event BeginPlay not firing.

Ok So I have racked my brains all night with this problem. I cant get Event BeginPlay to fire no matter what I do. I have GameModeBase and GameStateBase calling Super::BeginPlay() and Super::StartPlay(). I also have added a Parent: BeginPlay node in the blueprint editor with no success. Can anyone help me?

Thanks,

Product Version: UE 4.22
Tags:
more ▼

asked Jul 12 '19 at 03:18 AM in Blueprint Scripting

avatar image

AceHigh
6 2 8 9

avatar image MonsOlympus Jul 12 '19 at 06:45 AM

I know this sounds abit simple but did you check to see that youre actually using that GameMode when your running the game?

avatar image AceHigh Jul 12 '19 at 01:19 PM

Yes. However, it is my own custom gamemode.

avatar image GarnerP57 Jul 12 '19 at 01:26 PM

Each Level can override which GameMode it is using so either ensure that it is overriding with your Blueprint version of the GameMode or it is not overridden but set in "Maps & Modes" in the Project Settings.

avatar image AceHigh Jul 12 '19 at 01:32 PM

Yes its set in maps and modes and blueprint world override

avatar image GarnerP57 Jul 12 '19 at 01:58 PM

Make sure that if your GameMode inherits from GameMode that GameState inherits GameState and not GameStateBase. GameMode and GameState has to use the same variant.

avatar image AceHigh Jul 12 '19 at 02:00 PM

My GameModeBase inherits from GameModeBase and my GameStateBse Inherits from GameStateBase

avatar image GarnerP57 Jul 12 '19 at 02:33 PM

Okay and you are sure there is no run-time errors? Perhaps post a picture of what you got.

avatar image AceHigh Jul 12 '19 at 02:36 PM

alt text

this is what i'm trying to do. set a gameinstance vafriable

springarmset.jpg (63.4 kB)
avatar image w2lf Jul 12 '19 at 03:06 PM

alt text

alt text

I tried it in a new project 4.22 and it all works. Try print node before Event beginplay in GameStateBase, play and see if you get a message on the screen. (Also remove the override in WorldSettings.) If not then you didn't set your project settings right. Check that everything is set right. If it still doesn't work make a screenshot of GameStateBase and the Project settings so we are sure it's not a problem on your end. (Take the screen-shots exactly like I did in the pictures and also the WorldSettings GameModeOverride)

mygamestatebase.png (161.3 kB)
mapsmodes.png (45.1 kB)
avatar image AceHigh Jul 12 '19 at 03:13 PM

alt text

Ok so I've promoted MyGameStateBase to a blueprint but it still doesnt print anything and i'm sure i have everything setup properly could it be something in my c++ code then?

mapsandmodes.jpg (37.4 kB)
avatar image GarnerP57 Jul 12 '19 at 03:38 PM

If it is based on your own C++ GameModeBase and or GameStateBase then yes. Check if HandleBeginPlay is getting called in your GameState. If you are overriding HandleBeginPlay you have to call the Super class.

avatar image AceHigh Jul 12 '19 at 03:41 PM

My GameStateBase.h:

 UCLASS()
 class CUBEFACTORY_API AMyGameStateBase : public AGameStateBase
 {
     GENERATED_BODY()
         virtual void HandleBeginPlay() override;
 };

My GameStateBase.cpp

 void AMyGameStateBase::HandleBeginPlay() {
     Super::HandleBeginPlay();
 }
avatar image GarnerP57 Jul 12 '19 at 03:45 PM

If you aren't doing anything with the override you could also just delete the function so it isn't overridden. How about your constructor? can you show the code for that? please use the code tags so it is easier to read.

avatar image GarnerP57 Jul 12 '19 at 03:53 PM

HandleBeginPlay is public btw (see line 5)

  UCLASS()
  class CUBEFACTORY_API AMyGameStateBase : public AGameStateBase
  {
      GENERATED_BODY()
 public:
          virtual void HandleBeginPlay() override;
  };
avatar image AceHigh Jul 12 '19 at 04:09 PM

Ok So I removed the override because it wasnt being used. There is no constructor I dont know if that makes a difference but anyway

avatar image Shadowriver Jul 12 '19 at 04:09 PM

You 100% you calling Super::BeginPlay() on BeginPlay override?

avatar image AceHigh Jul 12 '19 at 04:10 PM

Yes I am sure.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Only other thing I can think of is you might have overridden tick and not called super, if thats even a thing.

more ▼

answered Jul 18 '19 at 02:08 PM

avatar image

MonsOlympus
1k 37 12 38

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question