playMaker

Author Topic: Restrict touch input to circle (SOLVED)  (Read 5349 times)

doppelmonster

  • Full Member
  • ***
  • Posts: 157
    • Grinder Games
Restrict touch input to circle (SOLVED)
« on: April 28, 2013, 11:12:13 PM »
Hello,
im trying to accomplish something like this:
http://forum.unity3d.com/threads/74292-Restrict-joysticks-movement-inside-circle-while-finger-is-outside-circle
or this
http://answers.unity3d.com/questions/42686/keep-object-inside-circle.html
with Playmaker.

In the Playmaker samples is also something similar: MouseClickToDrag

But it works only with Mouse Pick  (not touch) and i would like to be able to drag the touched object even if i am out of the circle with my finger. In the sample it resets to the center when outside. The object should at least stick to the edge where the finger exit the circle.

Thanks,
Matthias
« Last Edit: May 09, 2013, 06:34:05 AM by doppelmonster »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Restrict touch input to circle
« Reply #1 on: May 02, 2013, 03:05:55 PM »
Hi,

 ok, cool, thanks for the link. So which of these script is working best for you? I'll see about making it as an action.

bye,

 Jean

doppelmonster

  • Full Member
  • ***
  • Posts: 157
    • Grinder Games
Re: Restrict touch input to circle
« Reply #2 on: May 03, 2013, 03:46:11 AM »
Hi Jean,
Great!

I would prefer a basic action not a complete joystick script. So its universal usefull. Im not very good at math so i cant tell you which approach ist better.

Maybe you have also a look at this custom action which is going in a similar direction: http://hutonggames.com/playmakerforum/index.php?topic=2795.0

I would call the action something like:
Restrict Vector3 to Radius position

With public vars:
- Input: Vector3
- Radius (or min / max magnitude, that would make it possible to create a ring. could be of use....)
- axis xz, xy, zx
- Store result: vector 3
- every frame (dont know if NOT every frame is usefull. but its nice to have the option :-))

Thats what coming to my mind. This Action in combination with Mouse/Touch Actions should be sufficient to create virtual Joysticks, but is also good for placing something around an object (golf, poolbillard etc).

I just discovered that Mouse Pick Actions work fine on touch devices too, so thats oppening a whole lot new oportunities for me!




jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Restrict touch input to circle
« Reply #3 on: May 09, 2013, 03:27:20 AM »
Hi,

 To achieve this, you simply need to use the action "Vector3 Clamp Magnitude" and you are done. to Achieve a ring, clamp first with the max value, and then clamp with the min value and your vector 3 position will be within that ring.

Have you tried this already?

bye,

 Jean

doppelmonster

  • Full Member
  • ***
  • Posts: 157
    • Grinder Games
Re: Restrict touch input to circle
« Reply #4 on: May 09, 2013, 06:32:38 AM »
Hi Jean,
i searched through Vector3 actions before but i must have overlooked that (Maybe i also didnt understand what magnitude is good for...).


Works like a charme!

Thanks a lot,
Matthias