Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: doppelmonster 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 (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 (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
-
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
-
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 (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!
-
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
-
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