Hi folks,
I’ve got a fresh player controller class, in which I’ve overridden SetupInputComponent. In my SetupInputComponent method, I use the InputComponent to BindAxis for several different things, and I specify which method to call …
void AMasterChiefPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();
InputComponent->BindAxis("Turn", this, &AMasterChiefPlayerController::OnAxisInputTurn);
InputComponent->BindAxis("LookUp", this, &AMasterChiefPlayerController::OnAxisInputLookUp);
InputComponent->BindAxis("MoveRight", this, &AMasterChiefPlayerController::OnAxisInputMoveRight);
InputComponent->BindAxis("MoveForward", this, &AMasterChiefPlayerController::OnAxisInputMoveForward);
}
When I fire up the game, I immedietly get an error. The call stack shows that the error is coming from OnAxisInputTurn. The error is …
Exception thrown: read access violation.
this->Pawn was nullptr.
… and then from the UE4 editor …
Access violation - code c0000005 (first/second chance not available)
UE4Editor_Halo!AMasterChiefPlayerController::OnAxisInputTurn() [c:\users\ryan\projects\unrealshooter\source\halo\playercontrollers\masterchiefplayercontroller.cpp:16]
UE4Editor_Engine!UPlayerInput::ProcessInputStack() [d:\build\++ue4+release-4.19+compile\sync\engine\source\runtime\engine\private\userinterface\playerinput.cpp:1238]
UE4Editor_Engine!APlayerController::ProcessPlayerInput() [d:\build\++ue4+release-4.19+compile\sync\engine\source\runtime\engine\private\playercontroller.cpp:2471]
UE4Editor_Engine!APlayerController::TickPlayerInput() [d:\build\++ue4+release-4.19+compile\sync\engine\source\runtime\engine\private\playercontroller.cpp:4232]
UE4Editor_Engine!APlayerController::PlayerTick() [d:\build\++ue4+release-4.19+compile\sync\engine\source\runtime\engine\private\playercontroller.cpp:2135]
UE4Editor_Engine!APlayerController::TickActor() [d:\build\++ue4+release-4.19+compile\sync\engine\source\runtime\engine\private\playercontroller.cpp:4327]
UE4Editor_Engine!FActorTickFunction::ExecuteTick() [d:\build\++ue4+release-4.19+compile\sync\engine\source\runtime\engine\private\actor.cpp:134]
...
I’m confused though, because my OnAxisInputTurn method is empty. I make no attempt to reference the Pawn or anything.
void AMasterChiefPlayerController::OnAxisInputTurn(float value)
{
}
Does anybody have a clue why this might be happening? Below is the header for my player controller, as well.
UCLASS()
class HALO_API AMasterChiefPlayerController : public APlayerController
{
GENERATED_BODY()
public:
virtual void SetupInputComponent() override;
UFUNCTION()
void OnAxisInputTurn(float value);
UFUNCTION()
void OnAxisInputLookUp(float value);
UFUNCTION()
void OnAxisInputMoveRight(float value);
UFUNCTION()
void OnAxisInputMoveForward(float value);
};
Thanks!