Announcement

Collapse
No announcement yet.

Mobile Touch, Swipe, Tap & Dbl Tap! Get it here... for free ;)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Mobile Touch, Swipe, Tap & Dbl Tap! Get it here... for free ;)

    Hi everyone,

    After searching around and picking here and there from posts and tutorials that I've seen, I've setup a simple blueprint to detect Touch on mobile/tablet devices.

    It will detect:

    - Swipe (left, right, up and down)
    - Tap
    - Double Tap

    Particularity of the script: (Of course, you can change this to whatever.)
    - With a swipe left or right the Player will run continuously until a tap is done to stop the player. So you just swipe once and it will run and run...
    - Jump's while idle or running by swiping up.
    - Tap anywhere and the Player will stop and if he is stopped... well nothing!
    - Double tap and the player will fire while running or while in idle.

    Basically, I do it in two steps: First, I detect the desired action and secondly, I execute the desired action.

    This script as been adapted for a sidescroller game (3D or 2D). This means that the player will not rotate when changing direction, it will only flip even for a 3D character. But with some tweaking, I guess you can adapt it to what you want.

    Ok so first, you have to setup two enumerators.

    - 1 For Actions (Run, Jump, Idle, Stop, Fire, etc.)
    - 1 For Direction (left, right, face, tap) (face = facing direction)

    Then you setup your Character blueprint...

    How it works:

    - First, through the InputTouch event, I determine the Touch and release action. from there, I calculate the distance between both. If the distance if far enough (You can change it to what you want!), it's a swipe. Otherwise, it's a tap.
    - For the Tap, I then detect if it's a single tap or a double tap. Once that is done, I assign an action and a direction to it.
    - For the Swipe, I then detect if it's a horizontal swipe or a vertical one. Once that is done, I determine the direction of the swipe and assign it an action and a direction to it.
    - End of that part.
    - Through the Tick event, I execute the action and adjust the direction accordingly.

    Notice that before I assign a "new" action to a movement, I assign the already "done" action to a previousAction variable. I do this so that after jumping or shooting, our player can know what to do. Otherwise it would just stop after performing the fire and jump action.

    The fire action is still a WIP and as another freebie (Yes I'm generous :-P) I've included, but not connected, some nodes that can detect what you've tapped on based on their tags (can be modified to mesh name, etc.). You just need to connect the Print String node for it to work. You will also notice that there's one node for the mouse and one for the finger. When you debug, you connect the mouse one, like it is now. And when you send to your mobile, you connect the finger one.

    Don't forget to create your Enums before configuring your Character blueprint.

    (right-click to save the image to see them )

    Enjoy and feel free to leave your comments.
    Attached Files
    The Hangar Studio - Video Game Studio

    An I for an I
    (Imagination equals Innovation)

    #2
    For those who don't know, I find it much more convenient if you just right click -> open image in new tab. Or right click -> copy image URL -> Paste URL into URL bar.
    Marketplace Assets

    Advanced Mobile Input: Marketplace Page | Support Thread ――― Easy Input Remapping: Marketplace Page | Support Thread
    Multiplayer Blueprint Chat System: Marketplace Page | Support Thread ――― Closing Credits System: Marketplace Page | Support Thread
    Minesweeper Template: Marketplace Page | Support Thread ――― Maze Creator: Marketplace Page | Support Thread

    Comment


      #3
      Of course that another way of doing it
      The Hangar Studio - Video Game Studio

      An I for an I
      (Imagination equals Innovation)

      Comment


        #4
        I know not who you are, but my goodness did you just save me a LOT of hair loss! Been looking for a nice touch to move setup for some time and this is the only one that actually looks to be made for Paper2D! Very nice!

        Comment


          #5
          It's my pleasure

          Happy Game deving
          The Hangar Studio - Video Game Studio

          An I for an I
          (Imagination equals Innovation)

          Comment


            #6
            I would actually be very interested to hear your take on best way to do this exact sort of thing, but entirely as a touch to move. My goal is to have the player character move to the tapped location (along X only) when tapped on the lower half of the screen and throw an object at the tapped location on the upper half. Pretty sure I understand how to set up the "tap zones", just having some difficulty in adapting the swipe-move to a tap-move.

            Keep thinking I should be able to do this with the nav system, but that's been a bit of a ****-shoot. Thinking best way to go may be to set it up to spawn a trigger volume at the tap point and just apply offset until I overlap the trigger.

            In any case, excellent resource here and I look forward to any advice you may have for me! Thanks again!

            Comment


              #7
              I never did it myself but you can take a look at this link

              https://answers.unrealengine.com/que...ed-locati.html

              and take whatever information there and merge into this existing one.
              The Hangar Studio - Video Game Studio

              An I for an I
              (Imagination equals Innovation)

              Comment

              Working...
              X