I’m trying to transition from UE3 to UE4 and the input component isn’t cooperating with me. I’m currently using the tower defense example as my starting point but I have had the same problem no matter what template I pick. I have set up 3 actions, ‘LMB’, ‘RMB’, ‘MMB’ to bind to the 3 main mouse buttons. They are set in the input section of project properties. Here they are in the input ini file
+ActionMappings=(ActionName="ZoomOut",Key=MouseScrollUp,bShift=False,bCtrl=False,bAlt=False)
+ActionMappings=(ActionName="ZoomIn",Key=MouseScrollDown,bShift=False,bCtrl=False,bAlt=False)
+ActionMappings=(ActionName="InGameMenu",Key=Escape,bShift=False,bCtrl=False,bAlt=False)
+ActionMappings=(ActionName="LMB",Key=LeftMouseButton,bShift=False,bCtrl=False,bAlt=False)
+ActionMappings=(ActionName="RMB",Key=RightMouseButton,bShift=False,bCtrl=False,bAlt=False)
+ActionMappings=(ActionName="MMB",Key=MiddleMouseButton,bShift=False,bCtrl=False,bAlt=False)
In strategyspectatorpawn.h I have added
/** Handles the mouse scrolling down. */
void OnMouseScrollUp();
/** Handles the mouse scrolling up. */
void OnMouseScrollDown();
void OnLMBPress();
void OnRMBPress();
void OnMMBPress();
In strategyspectatorpawn.cpp
void AStrategySpectatorPawn::OnMouseScrollUp()
{
StrategyCameraComponent->OnZoomIn();
}
void AStrategySpectatorPawn::OnMouseScrollDown()
{
StrategyCameraComponent->OnZoomOut();
}
void AStrategySpectatorPawn::OnLMBPress()
{
int i = 0;
i = 69;
}
void AStrategySpectatorPawn::OnRMBPress()
{
int i = 0;
i = 69;
}
void AStrategySpectatorPawn::OnMMBPress()
{
int i = 0;
i = 69;
}
void AStrategySpectatorPawn::SetupPlayerInputComponent(UInputComponent* InputComponent)
{
check(InputComponent);
InputComponent->BindAction("ZoomOut", IE_Pressed, this, &AStrategySpectatorPawn::OnMouseScrollUp);
InputComponent->BindAction("ZoomIn", IE_Pressed, this, &AStrategySpectatorPawn::OnMouseScrollDown);
InputComponent->BindAction("LMB", IE_Pressed, this, &AStrategySpectatorPawn::OnLMBPress);
InputComponent->BindAction("RMB", IE_Pressed, this, &AStrategySpectatorPawn::OnRMBPress);
InputComponent->BindAction("MMB", IE_Pressed, this, &AStrategySpectatorPawn::OnMMBPress);
InputComponent->BindAxis("MoveForward", this, &AStrategySpectatorPawn::MoveForward);
InputComponent->BindAxis("MoveRight", this, &AStrategySpectatorPawn::MoveRight);
}
I set breakpoints on the ‘i = 69;’ lines and ‘StrategyCameraComponent->OnZoomOut();’ etc lines to catch when any are called, compile and launch editor with debugger, hit play and spam my mouse buttons, debugger doesn’t break. Scroll the mouse wheel and it hits the breakpoints checking the mousewheel binds. I’ve googled around and read the docs and I can’t figure out what I am doing wrong. The delegates should be getting called but they just aren’t.
Additonal info:
I tried naming the actions something different
I tried binding the actions to buttons on the keyboard, it still didn’t trigger
I noticed this not working on a function that was meant to spawn something under mouse cursor so it isn’t because my delegates are just assigning a funny number to an integer, the delegates aren’t being called at all