playMaker

Author Topic: Get touch bool (similar to Get Key)  (Read 1170 times)

dpomza

  • Playmaker Newbie
  • *
  • Posts: 2
Get touch bool (similar to Get Key)
« on: May 31, 2020, 03:57:35 AM »
I'm looking for an action that can check whether an object is being touched in real-time. Right now I have a working system on pc with the Get key action that returns a pressed/not pressed in real time. The function of it practically is primarily controllers. My initial struggle was that while controlling my character a quick tap on the key would trigger the transition to the next state but would not register in the next states "Get key up" action because the tap was too fast. I solved this by implementing the "Get key" action which checks every frame for the pressed state of the key. But I am struggling to find a touch equivalent for when I port my project to android.

Another idea I had was to get a "Touch count" which I found on the ecosystem. But when I tested it it took into consideration the whole screen rather than just that object's 2d collider. Would it be possible to limit a "Touch Count" to a single collider? That way if the count is zero = not touched/if the count is greater than zero = touched.

Any other ideas are also welcome.
Thank you.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: Get touch bool (similar to Get Key)
« Reply #1 on: June 04, 2020, 02:21:02 AM »
Hi,

 on touch screens, the first touch act as the mouse, so you can design your logic using the regular action for it and use the mouse during dev, it should work exactly the same on devices.

Another way would be to use the UI event system, which is often mistaken to only work for UI, but actually, if you replace the raycaster with a physicsRaycaster, then it works for all colliders in your world, and you benefit from all the pointer events built in Playmaker.

https://docs.unity3d.com/2018.2/Documentation/ScriptReference/EventSystems.PhysicsRaycaster.html






Bye,

 Jean