Problem with utilising both mouse and touch controls

0 favourites
  • 10 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Hi,

    I'm currently using the "touch gesture" option on my event sheets as the game I'm working on only uses left clicks. When I add "On left mouse click OR tap gesture" to get the player sprite to shoot, it fires double the number of bullets. Using "On object tapped" seems to fix this, but makes the game more awkward to control. Is there another option?

    Tagged:

  • I would use separate mouse and touch controls. Disable use mouse input in Touch properties and do separate events for Mouse Click and on Touch. You can dump these events into 2 groups ( mouse and touch ) and enable/disable each depending on players' first interaction with your game, for example if on any touch is triggered when they start game enable touch controls and disable mouse.

    I am sure there are other ways, but from my experience and games behaving differently on different browsers and when they are iFramed, this is a better way.

    Also if I remember correctly, for rapid fire shooting on any touch start worked better than on tap gesture.

  • Thanks for the advice, BadMario.

    I'm wondering if it would be easier to only use touch controls, but am having trouble replicating the "Set angle towards Mouse.X and Mouse.Y" for touch controls. Is there an equivalent?

  • There is Touch.X and Touch.Y

    you could set a global variable called something like aim or target and update it every tick with

    if mouse mode aim = angle(gun.X,gun.Y,Mouse.X,Mouse.Y)

    if touch mode aim = angle(gun.X,gun.Y,Touch.X,Touch.Y)

    Then fire in that direction ( aim )

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks BadMario. I've tried Touch.X and Touch.Y but when using these the player sprite no longer rotates to follow the cursor (presumably because there isn't one with touch control), and shooting enemies becomes impossible because I can only shoot from one angle. Am I missing something?

  • This is because mouse and touch behave a bit different overall.

    Mouse can get a position all the time, you don´t have to click.

    Touch can get a position BUT you can only get that position when you are actually touching. (How else would that work, there is no "mouse hover" equivalent)

    Holding click should work since you are simulating touch. If that isn´t what you want you´ll have to split those up as BadMario suggested.

  • Thanks for the info WackyToaster. Holding down does allow me to change the position, but the touch controls are still much less precise compared to the mouse. I found using "Is in touch" speeds bullets up a lot, but spawns far too many in one go. Is there a way to reduce this number?

    Also for some reason when I'm using touch controls the player sprite is positioned at an odd semi-upside-down angle - is there a way to fix this?

  • "Is In Touch" fires every tick. So any events spawning bullets would be running 60 times per second, assuming your game is running at 60fps.

    To slow this down you can add an "Every 0.1 seconds" before the "Is in touch" condition. This will only check if "Is in touch" is true every 0.1 seconds rather than every tick

  • Thanks. Another issue I'm having is that although the "set angle to Touch.X/Y" works, the player sprite always snaps back to its initial angle once I let go of the mouse button/touch pad. Is there a way to keep it in the angle it was at before the mouse/touch input was removed?

    [EDIT]: Never mind, I added the "Is in Touch" event and it's no longer snapping back to the original position.

  • There is Touch.X and Touch.Y

    you could set a global variable called something like aim or target and update it every tick with

    if mouse mode aim = angle(gun.X,gun.Y,Mouse.X,Mouse.Y)

    if touch mode aim = angle(gun.X,gun.Y,Touch.X,Touch.Y)

    Then fire in that direction ( aim )

    I've been trying to implement this but can't get it to work. Could someone please post a screenshot or similar so I can see how this should look on an event sheet?

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