If you watch the following video you will see that every time the user taps a little animation is played showing exactly where the user tapped on the screen. What is the best way to go about implementing this in engine?
I have been able to get this to work most of the time by adding touch input handling the player controller but when the user taps on a UMG widget that consumes the touch event the player controller doesn't get the event so the animation doesn't play. I did some searching and I can't find any good solutions that don't involve modifying the UButton code or making changes to all of the custom widgets I have currently in my game.
Can anybody point me in the right direction?
The solution to this problem in case anybody encounters it is to use a subclass of IInputProcessor which gets a chance to handle all touch/click/input events before it goes to slate & umg.
The header looks like this:
class FYourInputProcessor : public IInputProcessor, public TSharedFromThis<FYourInputProcessor>
{
public:
FYourInputProcessor();
virtual bool HandleMouseButtonDownEvent( FSlateApplication& SlateApp, const FPointerEvent& MouseEvent) override;
};
Implemention:
FYourInputProcessor::FYourInputProcessor ()
{}
bool FYourInputProcessor::HandleMouseButtonDownEvent( FSlateApplication& SlateApp, const FPointerEvent& MouseEvent)
{
//Put your custom input handling code here
}
Useage:
TSharedPtr<FYourInputProcessor> InputProcessor;
if (FSlateApplication::IsInitialized())
{
InputProcessor = MakeShareable(new FYourInputProcessor());
FSlateApplication::Get().RegisterInputPreProcessor(InputProcessor, 0);
}
if (InputProcessor.IsValid() && FSlateApplication::IsInitialized())
{
FSlateApplication::Get().UnregisterInputPreProcessor(InputProcessor);
InputProcessor.Reset();
}