Exclude an actor's reset() from getting called when resetlevel is called

Hi,

I want to exclude an actor from getting reset, i.e when GameModeBase->ResetLevel() is called, I don’t want actor’s reset getting called.

My CustomGamemode is subclass of GameModeBase class. In GameModeBase class, I see a ShouldReset(AActor*) function to check if an actor’s reset has to be called. But, I can’t seem to find anything that allows an actors reset from not being called.

Am I missing something?

Cheers!

AGameModeBase::ShouldReset(AActor*) is a BlueprintNativeEvent.
From AnswerHub: (How BlueprintNativeEvent specifier works? - Blueprint - Epic Developer Community Forums)

So, in your GameMode class you can store array of actor pointers(with convience functions like add/remove) and “override” ShouldReset function



bool AMyGameMode::ShouldReset_Implementation(AActor* Actor)
{
    return !ArrayOfActorsThatDontWantReset.Contains(Actor);
}


PS. Just a guess, not tested :stuck_out_tongue:

Thanks @Emaer , I did not give attention to BlueprintNativeEvent at all :frowning: I’ll give it a thorough read.

It’s a bit confusing on how override works here as neither ShouldReset() or ShouldReset_Implementation() are virtual functions. I’ll try it out and let you know :wink:

From the post https://answers.unrealengine.com/questions/434821/how-blueprintnativeevent-specifier-works.html, I gathered that ShouldReset_Implementation() will be used when ShouldReset() does not have a definition. So, I added ShouldReset_Implementation() function in my custom GameMode and defined it like
CODE:



// MyGameMode.h
bool ShouldReset_Implementation(AActor* Actor);

// MyGameMode.cpp
bool AMyGameMode::ShouldReset_Implementation(AActor* Actor) { return !ArrayOfActorsThatDontWantReset.Contains(Actor); }


It works! Thanks!

Great!

Yes. It just annoys me when Blueprints forces me to use a particular solution even though I don’t use BP.