Help with 8 direction touch analog stick

0 favourites
  • 10 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I'm having trouble with a touch analog stick for 8 direction movement. No matter what I try I can't get the player sprite to move true Left, Right, Up or Down. The player always moves at an angle like in an isometric game.

    I followed Jason Jarvis' tutorial on touch analog sticks, experimented with his examples and added some events for 8direction movement. Here's what it looks like:

    <img src="" border="0">


    I added the stuff below the red line. It works, but not the way it is suppose to work. Can someone help me with a solution?

    I was also wondering if it was possible to use drag and drop instead, but fix it where you can drag and drop anywhere on the screen and not just solely on the player sprite to move the player sprite around. Maybe place a tiled image covering the entire screen and have that connected somehow to the player with a drag and drop behavior and have the tiled sprite box reset to the center of the screen with not in touch, but not resetting the position of the player to the center along with it? I think the accuracy of drag and drop would be ideal for touch controls, if all possible.

  • Provided you only want the character to move Left or Right or Up or Down, and not diagonally, this might be what you're after.

    There are other ways to do it with drag/drop, but you would need two separate controls, one for Up/Down and one for Left/Right.

  • emoaeden

    Thank you. I appreciate you sharing your file with me, but I need for the player to move at angles. After the better part of the day, I wasn't able to fix the analog stick controls, but I did manage to make my drag and drop idea work. I found a way to do it in 3 events. I think with a little more tinkering, I can make it better. Here's the file for anyone who might be interested.

    Touch Controls using Drag and Drop:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • someone else helped me with this one, ill post you the picture when i get home. it helped a ton. basically you use character.controller.x or something along those lines.

  • Yes you can use Drag and Drop. But it has it's own pitfalls. however personally I think it's cleaner.

    1. Make sure the D&D object always stays at the root of the object list. Putting the DD in a folder will break the system.

    2. You need to work on fixing the offset of the D&D object. A D&D object doesn't center to the location of the touch. The D&D offset is where the touch occured.

    3. D&D that is currently being dragged doesn't like having the .setPosition used to recenter to the touch position.

    4. Ashley doesn't suggest using the D&D object for input control. Not sure why I thought the use of it was slick. But as mentioned in 1,2,3 it can break the system and there will be no BUG fix for it.

    As for you to fix your current problem due to angle. That's because there is no built in dead zone. So even the slightese off center will cause the other direction to trigger. Now if you can pixel perfect control then no problem. So I don't do that.

    on your

    deadzone = 10

    fangStick.x > fangPad.X

    change to

    fangStick.x > fangPad.X + deadzone

    fangStick.x < fangPad.X - deadzone

    alternativly you can instead check against

    fangStick.XP > 10 then simulate right

    fangStick.XP < -10 then simulate left



  • jayderyu

    Thanks for sharing the information about Drag & Drop controls. It's good to know. How long ago did Ashley make that suggestion? Maybe the issue with Drag & Drop was fixed since then? It seems to work fine for me, but I don't keep a lot of folders.

    And thanks a ton for the touch control fix! I don't think I would have figured out the deadzone issue on my own.

  • Is the 8 direction thumbstick example i placed in This topic what you were originally aiming for?

  • I'm working on an helicopter game and I need more than 8 directions because the player needs to avoid fast moving missiles and obstacles, but I think your thumbstick controls work great for 8 directions movement.

  • I think updating the touchstick-controls to create "realistic" helicoptermovement shouldn't be that hard, I guess it's a bit like the car movement with a few extra options..

    I've updated the example in the hope it will now work as expected on Iphone as well.. (did you have a look at all behaviours?)

    Instead of drag and drop I almost always use set to touch.x,touch.y with offset.

    So on touched

    • object set offsetx to touch.x-object.x
    • object set offsety to touch.y-object.y

    is touching

    -set object x to touch.x-object.offsetx

    -set object y to touch.y-object.offsety

    It has the same effect as using drag and drop, really.

  • I will try that, thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)