playMaker

Author Topic: Best practice cutting phone controls in two areas  (Read 4256 times)

Captaincrud

  • Junior Playmaker
  • **
  • Posts: 72
Best practice cutting phone controls in two areas
« on: April 17, 2017, 01:12:31 AM »
I want to run a project in landscape mode where the left and right side phone are separately controlled with no visible controls on the screen.  So if you press on left side its left button if you swipe on left side its a swipe on left side of the phone if you press down any were on the right side it is a right button press what's best practice for this in play maker? Picture is an example.


escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Best practice cutting phone controls in two areas
« Reply #1 on: April 17, 2017, 02:24:05 AM »
What you can do is use the touch info action to get the normalized touch position in X and then check if it is above or below 0.5. You can also check how long the touch took and set it as a tap if it was short, a press if it was longer than say 0.5 seconds (use store delta time). You can also use the delta position and check if the touch position has moved a set distance within a set time to check if it is a swipe and what direction it is in.

Hope that helps
« Last Edit: April 17, 2017, 02:39:00 AM by escpodgames »

Captaincrud

  • Junior Playmaker
  • **
  • Posts: 72
Re: Best practice cutting phone controls in two areas
« Reply #2 on: April 17, 2017, 01:02:50 PM »
I get the concept you're saying it would be great to see simple state machine for left that detects swipe up and button push for example if you happen to have the time.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Best practice cutting phone controls in two areas
« Reply #3 on: April 18, 2017, 02:02:53 AM »
Hi,

 I would actually try the UI way with two invisible buttons each taking one half of the screen, and the buttons would then be able to react to touches and drags ( for swiping)

 Have you tried this way?

 Bye,

 Jean

Captaincrud

  • Junior Playmaker
  • **
  • Posts: 72
Re: Best practice cutting phone controls in two areas
« Reply #4 on: April 19, 2017, 01:19:06 AM »
Jean could you go a little more in-depth with this?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Best practice cutting phone controls in two areas
« Reply #5 on: April 19, 2017, 02:14:58 AM »
Hi,

 basically, you create a UI canvas specifically for your controls, all elements will be invisible but will react to touch events.

-- make one button that fill the left half of the screen, and another that fill the right half of the screen. RectTransform allows you to create buttons that will automatically adjust layout to fit any screen sizes

-- now, you simply use the UI Proxies to catch UI events like click, drags etc etc.

-- You do know about the Unity UI proxy on the Ecosystem right?

 Bye,

 Jean

Captaincrud

  • Junior Playmaker
  • **
  • Posts: 72
Re: Best practice cutting phone controls in two areas
« Reply #6 on: April 19, 2017, 03:34:16 PM »
yeah just didn't know it sees drag events

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Best practice cutting phone controls in two areas
« Reply #7 on: April 20, 2017, 02:04:07 AM »
Hi,

 yep, drag event are supported too, check out the drag sample on the Ecosystem for a regular application, but you are perfectly ok to use drag and not drag anything at all and just watch for a possible swipe or something.

Bye,

 Jean