Search code examples
c++unreal-engine4mobile-development

How to receive touch-hold-drag event in Unreal Engine 4 Mobile Game Development C++


I'm a UE4 newbie and am starting to make my very first mobile game with this engine.

I'm really having trouble with implementing the event as described in the title. Basically, there are a bunch of tiles on screen. All I want is when the user touches any tile and hold his finger and drag it across other tiles, all the 'touched' tiles will change color.

What Action/Axis Mappings do I need to add in Engine-Input? I also tried using TilekMesh->OnInputTouchEnter.AddDynamic(this, &AMyProjectBlock::OnFingerPressedBlock);, but even when I touch-hold and drag, the tiles do not seem to change color. But when I use OnInputTouchBegin instead, it works successfully but I don't want to singly touch and let go each tile. Any help would be greatly appreciated.


Solution

  • The code for adding a dynamic event to touch enter is already correct. What I missed was that the touch over events must be enabled in the PlayerController like so:

    bEnableTouchOverEvents = true;
    

    And that should do the trick.