I think that in OPressed(), the variable called ‘MyMainMenu’ might be still a nulltpr. Let’s try creating some protection. I’d go for if(!ensure(MyMainMenu!=nulltpr)) { return; } or if(MyMainMenu==nulltpr) { return; }
Oh, you’re right of course. But I have noticed another possibility of a nullptr: directly in your SetupInputComponent() - probably your InputComponent is null. There’s my code: if (GetPawn() == nullptr) { return; } auto PlayerInputComponent = GetPawn()->FindComponentByClass<UInputComponent>(); if (!ensure(PlayerInputComponent != nullptr)) { return; } PlayerInputComponent->BindAxis(TEXT("MoveForward"), this,...
Why do you think so? Doesn’t the binding work properly? If because of the SetupInputComponent() your project was crashing, it must be called. Maybe there are some logs logging out at the beginning?
After looking at other posts I discovered that what was needed was to call the function of the parent class, Super :: SetupInputComponent (). This function initializes the InputComponent if it is equal to NULL.