Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TouchScript — multi-touch library for Unity [RELEASED]

Discussion in 'Assets and Asset Store' started by valyard, Mar 6, 2013.

  1. gretty

    gretty

    Joined:
    Jun 20, 2012
    Posts:
    72
    Hello

    In my game I have a FullScreen Layer that detects all gestures; touching anywhere on the screen will rotate or pan the camera. When someone presses anywhere on the screen a menu appears.

    I have a problem that when ever someone Pans a press event is also sent. So the menu always appears when they are panning which isn't supposed to happen.

    The order of events sent by TouchScript when someone pans is (knowtice how a press message is sent):
    - Press recognized
    - Press Potential
    - Pan Started

    The order of events sent by TouchScript when someone presses is:
    - Press recognized
    - Press Potential

    How can I determine if a person really has pressed and that they are not panning? How can I distinguish between a Pan and a Pres
     
  2. Deleted User

    Deleted User

    Guest

    How can I write custom gestures recognition? The tutorial isn't started. :( I want to be able to recognize stars and other shapes.
     
  3. Merry11

    Merry11

    Joined:
    Jan 30, 2014
    Posts:
    3
    Hi,
    your Project is great, but I can't seem to find a way to dynamically add a full screen touch layer.
    The Problem is I have a Menu that is being created in the game overlaying the game screen.
    This Menu is a Prefab with a Fullscreen layer.
    Since I have only one Camera, global and MainCamera settings give the same results.
    When I don't create it dynamically and just place it manually I get all gestures from the full screen, when I create it manually I only receive touches directly on the object.
    I guess that the automatically created camera layer for the main Camera somehow interferes with the fullscreen layer, but how can i stop that from being created?
     
  4. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
  5. AntonioEsse

    AntonioEsse

    Joined:
    Jun 27, 2014
    Posts:
    4
    Valyard thanks for this plugin, i'm using it on an android 2d games and works very well. I'm using interstitial adverts and i have a problem with press gesture.
    1. The press gesture is active
    2. A full screen AD is called
    3. The finger is lifted to close the advert but obviously the release gesture isn't executed because the game is paused
    4. Closed the Ad the press gesture is still active without a way to stop it
    How can i cancel this touch point before or after the advert? thanks
     
  6. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    I see. First, can you use ReleaseGesture to open the AD not PressGesture?
    I need to test what happens with ReleaseGesture in such scenario. It might be that it receives TouchesCancelled events but don't handle them. You also can try to copy the code (https://github.com/InteractiveLab/TouchScript/blob/master/TouchScript/Gestures/ReleaseGesture.cs) into your own gesture and add touchesCacelled method to see what's going on.

    Unfortunately I'm on vacation and not going to work on TouchScript till September.
     
  7. daudau505

    daudau505

    Joined:
    Jul 19, 2014
    Posts:
    27
    Hi, I was wondering if any can help me out with this script using playmaker?
    So here is the problem,when you first a touch a button, it would not release until you touch it the second time. Than it will work properly. I have attached a sample. thank you.
     

    Attached Files:

  8. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Hi Valentin,

    Amazing Touch Script package. Kudos for sharing this work.

    I just downloaded the package and going through the included examples. I'm on a Mac, Unity 4.5.3p1 IOS pro.
    I tested the pan example in the editor and found a strange behavior when tapping the button. Based on the script, each time I click on the button the base should rotate. It doesn't seem to be rotating all of the time.

    Here is a video.

    https://dl.dropboxusercontent.com/u/48378123/TouchScriptPan.mp4
     
  9. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    First, thank you for this excellent asset. I watched your Unite2012 video and was very impressed with your work.

    I'm trying out your asset for the first time and I have a few questions that are not covered in the FAQ.

    1) It's not clear how all the packages fit together. If I'm working on a multiplatform game do I import each package or just the TouchScript package?

    2) With the Windows Store Package and Examples the mouse is not recognised as a touch source. I can create a build, deploy it to my Surface RT and see that the touch input works. But mouse input does not work on my Surface RT device or my dev machine when I run the project locally.

    If I use the Windows8 package/examples and build an exe, mouse input works. What am I doing wrong?


    D'oh! 5 minutes with the first tutorial and I've figured out my issue with the mobile/mouse input.

    A little clarification on my first question about how the packages fit together in a multi platform project would be great.

    Thanks again for this great asset.
     
    Last edited: Sep 3, 2014
  10. nmax

    nmax

    Joined:
    Feb 13, 2010
    Posts:
    6
    Hi !

    Nice work with TS !

    What is the best approach to create orbiter like MouseOrbit script?

    Thanks !
     
  11. idunnuhow

    idunnuhow

    Joined:
    Apr 16, 2014
    Posts:
    23
    Hello,

    How do i use gesture.HasTouch(?), it needs an ITouch parameter but i don't know how to get it. can sm1 put a code example on how i can use it?
     
  12. Kabbs

    Kabbs

    Joined:
    Mar 17, 2013
    Posts:
    4
    Thanks so much for the script.
    I'm wondering if I'm doing this right:

    I'd like to implement camera panning and zooming using TouchScript.
    In the Layers example scene, this (well, at least panning) is implemented using a SimplePanGesture and Tranform2D on the whole scene.
    So panning would translate the scene, not the camera. This seems excessive. Is this really the best way to implement camera panning?
    If not, how should one do it?

    Thanks.
     
  13. MS80

    MS80

    Joined:
    Mar 7, 2014
    Posts:
    346
    Hello!

    Has anyone got the new ui system (uGui) to work with touchscript?? A custom touch layer should give us "sort of" support for gui buttons, but I have no idea how to create it?!

    Combination of uGui and TouchScipt would be superb!!!
     
  14. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Hello everyone.
    I set up a dedicated message board for TouchScript questions!
    Please post all your questions and feature requests there!
    I also moved some of the questions from this topic to the new message board.


    http://touchprefab.com/

    Thank you.
     
  15. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    Thanks @valyard! I hope you had a great vacation.
     
  16. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    Hey @valyard, I just tried to register on your new site but I have not received the activation email. It's in my spam. Is the SMTP working?
     
  17. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Hm.
    It seems that smtp is not indeed working.
    I activated your account manually and will try to fix this asap.
     
  18. MS80

    MS80

    Joined:
    Mar 7, 2014
    Posts:
    346
    Thank you @valyard!

    It seems registration works without activation email....
     
  19. SOF1963

    SOF1963

    Joined:
    Oct 16, 2014
    Posts:
    2
    I'm struggling with the fact that it appears the Flick example has been dropped from the package? Combine that with the lack of good documentation and I can't figure out how to implement simple flick detection. I'm also unclear on whether or not by default it can inform your script of the direction of the flick.
     
  20. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Hey, SOF1963.

    I'll add Flick sample back.
    Otherwise it's pretty simple.

    Please post all your questions on the dedicated forum:
    http://touchprefab.com/
     
  21. SOF1963

    SOF1963

    Joined:
    Oct 16, 2014
    Posts:
    2
    Thanks for your response. After looking through the existing examples again, I was able to figure out how to implement the flick gesture on an invisible plane attached to my camera in order to move the camera. Now I just need to figure out how to determine the direction of the flick.
     
  22. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    Hi, great free plugin.

    I've been lookin at the tutorials and docs and i see that we need to attach script to the object we want to interact with to receive a call back.

    But what if i want to be able to touch anywhere on an empty screen and have the position of the tap sent to a gameobject located elsewhere. How would i do that since there's no object to attach anything to. Something like Inpuit.getmousebutton(0), which gets information from anywhere on the screen.

    I have a function in update() on a 2D object which rotates it in the direction of a mouse click on screen(and updates the position continously as long as mouse button is held down:

    function moveOnMouseDown(){ //default position face upwards
    if(Input.GetMouseButton(0) && !touching && !paused){
    mousePos = Input.mousePosition;
    mousePos.z = -Camera.main.transform.position.z; //The distance from the camera to screen
    lookPos = Camera.main.ScreenToWorldPoint(mousePos);
    lookPos = lookPos - ch_transform.position;
    // Debug.Log(lookPos + " " + (mousePos - transform.position));
    angle = Mathf.Atan2(lookPos.y, lookPos.x) * Mathf.Rad2Deg;
    angle -= 90;
    ch_transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
    }
    }


    How would i use touchscript to recreate this using touches?
     
  23. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    The best method would be to have a parent for all your objects with FullscreenLayer attached. It will take all touches from a camera as you want.

    Another way is to subscribe to TouchManager's events like it's done here:
    https://github.com/InteractiveLab/T...xamples/General/Input/Scripts/InputExample.cs

    Please post all your questions on the dedicated forum:
    http://touchprefab.com/
     
  24. srmojuze

    srmojuze

    Joined:
    Mar 18, 2013
    Posts:
    127
    Hi, for UnityScript with TouchScript and PanGesture, the events are:
    OnPanStart, OnPan, OnPanComplete
    (from https://github.com/TouchScript/TouchScript/wiki/Gestures)

    So you would need to have different functions. So to detect ending of pan gesture, use a function (which PanGesture sends a message to) to handle when the pan gesture ends.

    So in UnityScript, have these for example:

    function OnPanStart(sender: PanGesture)
    {
    Debug.Log("pan started");
    }

    function OnPan(sender: PanGesture)
    {
    Debug.Log("pan is happening!");
    }

    function OnPanComplete(sender: PanGesture)
    {
    Debug.Log("pan finished");
    }

    For non-C# people TouchScript can be confusing, including the Transformer2D script example.

    But for UnityScript, all you need to write are the handlers, that is

    OnTap(sender: TapGesture)
    OnPan(sender: PanGesture)
    etc.

    TouchScript will trigger the events and you just handle it on the UnityScript side.

    The parameters sent to your UnityScript function will have information about the gesture.

    For example, OnPanComplete(sender: PanGesture) ... sender.LocalDeltaPosition will have information about what the pan movement was.

    What is in "sender", well, it will have the "properties, etc." for each gesture type (note inheritance) as per http://touchscript.github.io/docs/html/N_TouchScript_Gestures.htm

    Good luck, took me a while to figure it out, I might just be getting the hang of it!
     
    Last edited: Nov 7, 2014
  25. Quaker_SDR

    Quaker_SDR

    Joined:
    Jun 21, 2013
    Posts:
    39
    Touchscript.dll file is missing..!!!
     
  26. tuxpeppe

    tuxpeppe

    Joined:
    Jul 25, 2014
    Posts:
    1
  27. Kellyrayj

    Kellyrayj

    Joined:
    Aug 29, 2011
    Posts:
    936
    I'm receiving an error when importing the Playmaker actions.

    "Assets/TouchScript/Modules/PlayMaker/Actions/GestureStateChanged.cs(25,24): error CS0426: The nested type `GestureState' does not exist in the type `Gesture'"

    Any clues?
     
  28. famadori

    famadori

    Joined:
    May 6, 2014
    Posts:
    2
    Someone can help me in two questions?

    1 - I am using TapGesture, PressedGesture and ReleasedGesture. how do I not need to always add the three in myself every time? How do I create a class to be able to reuse the three together?
    2 - I am creating an animation in PressedGesture and ReleasedGesture returning this animation, however the animation ReleasedGesture only runs when shooting the finger from the screen,
    is there any way to know when the finger was dragged off the button and run the animation?

    Thanks
     
  29. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    Hey guys, if you want to get answers from the developer, post your questions at the dedicated forum: http://touchprefab.com/
     
  30. serhilk

    serhilk

    Joined:
    Jul 10, 2013
    Posts:
    4
    Hi All!!

    I'm trying touse TouchScript to control my input from device or mouse. I want to know how can I modify the Tap example to explode the cube instead of making a tap, when I'm moving the finger over the cube?

    This way, I want to press the screen and move the finger over the cubes that will explode (without releasing the finger) and when I finally release the finger the cube stop exploding, although I tap and move the finger over the screen again.

    How can I achieve this gesture behaviour?

    Thanks in advance
     
  31. EricRockdriguez

    EricRockdriguez

    Joined:
    May 24, 2013
    Posts:
    1
    Hi !!
    I am testing this tool and it looks pretty helpful, How can I see more that two touches on screen? I have tried keeping pressing the alt key and clicking the mouse button, but I just can see two touches.

    Thanks.
     
  32. ludos

    ludos

    Joined:
    Nov 14, 2011
    Posts:
    55
    afaik you can only get 2 touches using the touch emulation. what i use is a tablet with an app emulating tuio data (for example TuioPad on iPad).
     
  33. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Right. It's hard to emulate several touch points just with a mouse.
     
  34. Deleted User

    Deleted User

    Guest

    Hi. I want to implement hold button, how to use the longpress? I tried but doesnt work.
     
  35. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    hello.. been digging through this, and it is quite nice. I've had a look and there seems to be something missing from the 6.8 solution:

    OSCsharp\
    TUIOsharp\

    should be found in: (these referenced projects do not exist)
    "TouchScript.Inputs\TUIOsharp\OSCsharp\OSCsharp.csproj"
    "TouchScript.Inputs\TUIOsharp\TUIOsharp\TUIOsharp.csproj"

    is this just a remnant of past project/dependencies that can be cleared away?

    (i'll take a look at earlier versions to see if they're included)
     
  36. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
  37. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    the references are there (atleast in the .sln), but the projects themselves seem to be missing from the directory structure.. visual studio flags them in the solution explorer as missing. (just a grey'd icon with a ? mark)
     
  38. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    You probably haven't fetched submodules after cloning the repo.
     
    tswalk likes this.
  39. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    yes, you're of course right :D

    I just needed to put everything together after realizing the missing projects were separated... fixed.

    thanks very much... this is a "learn through exploration" session.


    if by chance you get a moment... can you take a look here at my question about universal windows 10 and store apps:

    http://touchprefab.com/viewtopic.php?f=4&t=24355

    thank you!
     
  40. Deleted User

    Deleted User

    Guest

    Hi! I haven't figured out how to implement the following, simple scene:
    -the background is a touch detector for pan, scale (camera movement) - I did this using full screen target
    -objects in the scene can be tapped

    My problem is, I want the background detector to fire for pan, scale gestures that originate on the scene objects. I figured this would be possible since they can only handle tap gestures, so other gestures would be passed on, but no.

    I tried setting it up using layers and friendly gestures but it's not working. Can anyone help me figure this out?

    Thanks!
     
  41. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    940
    @valyard Hi, I need to replace fingergesture to support our non-game app that works on multitouch windows pc, android and iOS.

    Is this a good replacement?

    Is there any problem on mobile platforms?

    Thanks a lot,
    Stefano
     
  42. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    Hey guys, you should post your questions to the official forum for this asset: http://touchprefab.com/index.php

    At the very least, you'll get your questions answered faster.
     
  43. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    940
    ....no answer both here and official forum :(
     
  44. Deleted User

    Deleted User

    Guest

    hi all. I have updated the touchscript plugin for the new version, but theres not a example for gestures on a 2D game yet. someone knows if theres a youtube channel, or documents, or tutorial for use this plugin in 2d games?

    thx
     
  45. jdean2k6

    jdean2k6

    Joined:
    Jan 31, 2016
    Posts:
    1
    I am only able to get gestures working on game objects with textures set via the SpriteRenderer. Once I select a PNG file as the sprite renderer gestures arent detected. Any help?
     
  46. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    touchscript appears to be dead.
     
  47. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    No, it's not.
     
    luniac and tswalk like this.
  48. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,042
    @valyard do you have planned gestures support with uGUI? Now If I'm not wrong it's still necessary to attach a collider to each object in order to work.

    I think it's the only feature that makes it almost perfect and should be built-in with Unity.

    That makes me think, If you are from Unity Staff and TouchScript is free (you don't want to make money with it) why you don't talk to your team in order to integrate it in the core? It whould be awesome.

    Thanks!
     
  49. samuelthe2nd

    samuelthe2nd

    Joined:
    Apr 11, 2016
    Posts:
    1
    Is there a way for the drag script to drag on different axis than X and Y, preferable X and Z?
     
  50. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Guys please ask questions at http://touchprefab.com/
    I'm not checking this thread frequently.

    @N3uRo: I'm working on better UI support. I can't promise but probably TouchScript will be tightly integrated with the new input system in development. But otherwise it is fine as it is right now.

    @samuelthe2nd: yes, you need to set the appropriate drag plane normal, i.e. (0, 1, 0) for X/Z.
     
    tswalk likes this.