Im tring to bind the action “ChangeVerse” in my C++ GameMode, yet when its called, it crashes the editor. I had this occur on an actor but manually checking “Auto Receieve Player Input” worked. I want to set this option in C++ but i do not understand the function AutoReceiveInput. The documentation I have found is poor. Any help on using AutoReceiveInput or another solution.
The problem you’re experiencing is that the InputComponent is NULL inside the GameMode during BeginPlay(), As Anshul mentioned. While the recommended thing to do is to setup input in the PlayerController as eXi mentioned I can understand wanting to setup input from the game mode; so here’s a way it can be done:
void ACustomGameMode::BeginPlay()
{
Super::BeginPlay();
UWorld* World = GetWorld()
if (World) {
World->GetFirstPlayerController()->InputComponent->BindAction("CustomEvent", IE_Pressed, this, &ACustomGameMode::CustomFunction);
}
}