Download

BeginPlay GameMode and Hud inherit from C++ doesen't work

Hi,

I’ve spent a few hours searching for a solution.

I have a gamemode blueprint wich inherit from a gamemode c++, and an HUD blueprint wich also inherit from C++.

In both case my beginplay doesn’t work.

I made several trials, and it appears it also block every beginplay such in a levelblueprint.

Any idea why ?

thanks for your help…

Do not post a C++ question without showing the class causing you problems; it’s pretty useless and people won’t try to “guess” what your problem is…

Btw, I imagine you are not calling ‘Super::BeginPlay()’, so your overridden function will not work.

I am calling that’s why it’s Strange.

And I just saw that it also freezing anything, such as emiter.

Here is my gameMode c++



// Fill out your copyright notice in the Description page of Project Settings.

#include "LaPetiteHistoire.h"
#include "Items/Item.h"
#include "BaseGameState.h"
#include "BasePlayerState.h"
#include "BaseHUD.h"
#include "BasePlayerController.h"
#include "LaPetiteHistoireGameModeBase.h"




ALaPetiteHistoireGameModeBase::ALaPetiteHistoireGameModeBase()
{
    CanChangeWorld = false;
    playtime = 300;

    PlayerStateClass = ABasePlayerState::StaticClass();
    GameStateClass = ABaseGameState::StaticClass();
    //HUDClass = ABaseHUD::StaticClass();
    PlayerControllerClass = ABasePlayerController::StaticClass();
    //static ConstructorHelpers::FObjectFinder<UClass> HUDClass(TEXT("Blueprint'/Game/BaseHUD_BP.BaseHUD_BP'"));

}

void ALaPetiteHistoireGameModeBase::BallPickedUp()
{
    ABaseGameState* MYGS= Cast<ABaseGameState>(GameState);
    if (MYGS)
    {
        MYGS->AddNumBallCollected(1);

    }
}

void ALaPetiteHistoireGameModeBase::EndtimePlay()
{

}

void ALaPetiteHistoireGameModeBase::BeginPlay()
{
    Super::BeginPlay();
}

Finaly found the solution when I change my gamemode class inherit.
It was inheriting gamemodebase, and I change it to gamemode.

Suddenly everything works.