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

[RELEASED] Easy Touch

Discussion in 'Assets and Asset Store' started by Hedgehog-Team, May 8, 2012.

  1. ZINI-NGR

    ZINI-NGR

    Joined:
    Jan 28, 2013
    Posts:
    20
    Hi, i have a question.

    an easy joystick has 3 draw calls..can i reduce this?
    (ex> use an atlas.. or use NGUI or etc.)
     
  2. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi,

    For ShinyTaco
    EasyTouch no effect on the sound, so I have no idea where your problem could come. Example would be greta

    ZINI - NGR
    Yes EasyJoystick use Unity GUI (so 1 draw call per texture). You may gain 1 drawcall if you do not show the dead zone. With Unity 4.X the unity GUI is 10X faster than 3.X. We already writing applications for IOS and Android, and 3 drawcalls not cause performance loss

    Implement a system Ngui or forced users to have Ngui would be not good for evryone, and especially the price would be more than 20 dollars
     
  3. prototype7

    prototype7

    Joined:
    Aug 29, 2012
    Posts:
    12
    Hi Nico,

    i've been playing around with EasyJoyStick these days, anyway i am happy to know unity4x GUI is faster.

    My Question is
    1) i have NGUI too, could you tell me how implement a system NGUI for EasyJoyStick,
    crete new atlas(touch, area texture, etc), create a new widget(sprite) inside the Panel,
    add EasyJoyStick and EasyTouch, and than i am lost dunno how to calculate Dead, Touch,Area....

    2) touchSizeCoef in EasyJoyStick , if the value is zero all the time why do you use it?

    Thanks in advance
     
  4. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Nicolas, do you have any idea what can cause this behavior?
     
  5. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    To Tripwire :
    I haven't any ideas, do you have an example scene ?

    To Prototype 7
    Can you have more information about GUI in unity 4.X here :
    http://unity3d.com/unity/whats-new/unity-4.0

    For NGUI
    I can't say exactly how to deal with Ngui. You will have rewriting the part of which is in EasyJoystick method On_GUI (). Because I do not use Ngui, because the impact on performance between 1 and 3 drawcall is null

    touchSizeCoef
    touchSizeCoef is a variable to manage the behavior of the touch, restricted to the area or not restricted.

    This value therefore falls into account in all calculations

    But what is the simplest ?:
    1 - Take into account this value all the time even equal = 0
    2 - Or do a test on each calculation to not take into account when it is equal to 0

    Nicolas
     
  6. ShinyTaco

    ShinyTaco

    Joined:
    Sep 4, 2012
    Posts:
    70
    Hey, no problem. I'm not sure what is wrong, but it is strange.

    Another quick question.

    Is there a way to have separate controls with EasyTouch Joystick? I would like to have the controls to act a certain when when the player isGrounded and another when he is not.

    Any ideas?

    Thank you.
     
  7. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi ShinyTaco,

    You can do this, with event Mode or include mode.
     
  8. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi everyone,

    The next version of Easy Touch is ready soon,

    Here are the some new features that will be present :

    * NGUI support => Allow you to don't send EasyTouch event when your touches are hover NGUI panel.
    * Virtual screen engine for EasyJoystick, that allow to anchor joystick to keep size and position relative to screen resolution.
    * Management of limited rotation angle on direct mode for easy joystick
    * Enable or disable X or Y axis of an joystick that allow to have a one direction joystick
    * New events for joystick

    * And a new EasyTouch extension ....

    * and much more

    This release will be ready in one or two weeks.
     
  9. ShinyTaco

    ShinyTaco

    Joined:
    Sep 4, 2012
    Posts:
    70
    Hey Nicolas,

    Is there a way to set position with screen.width and screen.height instead of pixels? Also can you set the size with that instead? So, we can have same size of the joystick for retina display?

    Thanks.
     
  10. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi Shiny,

    Yes , it's coming soon, it's that I called in my last post :
    * Virtual screen engine for EasyJoystick, that allow to anchor joystick to keep size and position relative to screen resolution.

    This release will be ready in one or two weeks.
     
  11. sstublic

    sstublic

    Joined:
    Nov 12, 2012
    Posts:
    13
    Hi!

    I'm really liking EasyTouch.

    I have one problem. I want to process user touches when the game is paused (Time.timeScale == 0), but EasyTouch doesn't seem to work correctly - it's not raising touch events!

    I've seen in your source files that you are using Time.time to determine touch durations (shouldn't you be using time.realtimeSinceStartup?)

    Am I doing something wrong and is there a way around this?

    Thanks
     
  12. sstublic

    sstublic

    Joined:
    Nov 12, 2012
    Posts:
    13
    One more additional question:

    I'm having trouble thinking of a clear way to cancel events.
    For example:
    I catch a simpletap event and do something with it. After that I DON'T want next tap to raise doubletap event EVEN if it was quick enough. It results in inconsistent user interface.
    In other words I want to be able to consume or reset future events based on current touch. I used this simpletap and in its event I'd like to do something like EasyTouch.CancelCurrentDoubleTap

    Same applies to TouchStart and SimpleTap. If I use the TouchStart event and do something based upon it (I used TouchStart as a workaround for problem from previous post), later a SimpleTap would be raised starting with the TouchStart I already processed. In similar manner I would like to do something like EasyTouch.CancelCurrentTouch

    Maybe I'm going about this in a completely wrong direction.

    Any help / suggestion would be appreciated!

    Thanks!
     
  13. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi Sstublic,

    I'll test it the replacement of Time.time by Time.realTiem, if it works, it's will be available in the new release that is coming soon. Thank you to raise me this issue

    For you second need, I will see what I can do ...

    Nicolas
     
  14. sstublic

    sstublic

    Joined:
    Nov 12, 2012
    Posts:
    13
    Thank you,

    any ideas for workarounds are also welcome!
     
  15. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    May be you can try with some boolean when you receive the touchstart, and you ll test this boolean in other event before to do an action
     
  16. fadzuli

    fadzuli

    Joined:
    Sep 22, 2010
    Posts:
    15
    Hi Nicholas

    Can the gesture class also contain normalized values of delta position, delta pinch/twist, independent of screen size?
     
  17. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi fadzuli,

    Yes, it's possible, but I will prefer to add method at the gesture class than a new members.

    for sstublic :
    It done for timescale
     
  18. sstublic

    sstublic

    Joined:
    Nov 12, 2012
    Posts:
    13
    Great! How do I get updated version?
     
  19. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    I 'm working on the next release :), I'm think it ll be ready in one or two week.

    If you can't wait, send me you invoice number on : The.hedgehog.team@gmail.com, I can send you a beta version

    Nicolas
     
  20. alfchee

    alfchee

    Joined:
    Jun 14, 2012
    Posts:
    19
    Hi!! this thread is very long, I don't know if someone else have been asked this before.
    What I want to know is if there is an accurate way to know the object over I'm swiping on; actually I'm doing this:

    Code (csharp):
    1. void On_Swipe(Gesture gesture)
    2. {
    3.    GameObject picked = EasyTouch.GetCurrentPickedObject(gesture.fingerIndex);
    4.                
    5.     if(picked != null)
    6.     {
    7.       if(picked.name == "name")
    8.         // do something
    9.     }
    10. }
    I don't know if this is right, but sometimes I don't get interaction with the object over the swipe.

    Greetings
     
  21. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi Alchee,

    Yes it's the right way.

    In Unity you're depending of FPS, so if do a very quick swipe gesture you d'ont receive each position. May be a good way would be to test each position between startposition and current position with a step

    It's giving me an idea for the next release
     
  22. alfchee

    alfchee

    Joined:
    Jun 14, 2012
    Posts:
    19
    Hi Hedgehog,

    And thanks for the fast answer. Indeed that was my first idea about how it should be made, but I don't realize of how to implement it. How do I test that? There is some kind of path saved for each swipe described? or What can I do?

    Thanks again.
     
  23. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    When you receive swipe event, Gesture parameter always containt the startposition and the current position. With this you can have the linear equation to test point with a raycast
     
  24. CrazyMinnowMichael

    CrazyMinnowMichael

    Joined:
    Jun 4, 2012
    Posts:
    5
    I'm having some trouble getting IsRectUnderTouch or IsInRect to return true when I believe it should be.

    In the example below, this script is attached to the EasyTouch object and has a public property of type EasyTouch that has been bound to the instance. I'm positive the Rectangles (jumpRect and attackRect) are accurate because I'm using OnGUI to draw textures in the specified positions. I've also tried this in the [On_TouchDown] method without success. Any help you can offer is appreciated.

    I'm using Easy Touch 2.5.

    Code (csharp):
    1.  
    2.     void OnEnable()
    3.     {
    4.         EasyTouch.On_TouchStart += On_TouchStart;
    5.     }
    6.    
    7.     void OnDisable()
    8.     {
    9.         EasyTouch.On_TouchStart -= On_TouchStart;
    10.     }
    11.    
    12.     void OnDestroy()
    13.     {
    14.         EasyTouch.On_TouchStart -= On_TouchStart;
    15.     }  
    16.    
    17.     public void On_TouchStart(Gesture gesture)
    18.     {
    19.         if (EasyTouch.IsRectUnderTouch(jumpRect))
    20.             Debug.Log("IsRectUnderTouch, Jump: " + jumpRect.ToString());
    21.        
    22.         if (gesture.IsInRect(jumpRect))
    23.             Debug.Log("IsInRect, Jump: " + jumpRect.ToString());
    24.        
    25.         if (EasyTouch.IsRectUnderTouch(attackRect))
    26.             Debug.Log("IsRectUnderTouch, Attack: " + attackRect.ToString());       
    27.        
    28.         if (gesture.IsInRect(attackRect))
    29.             Debug.Log("IsInRect, Attack: " + attackRect.ToString());
    30.        
    31.         Debug.Log("On_TouchStart is firing");
    32.     }  
    33.  
     
  25. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi Outerringz,

    Yes, this is a problem that comes from Unity that doesn't manage the same coordinated orgine for touches and GUI.

    Origine for touches (0,0) is on lower left corner
    Origine for GUI (0,0) is on Upper left corner

    If you when to test a GUI rect, you must transform your data like this :

    Rect myNewRect = new Rect( guiRect.x, Screen.height -guiRect.y, guiRect.width, guiRect.height);

    May be I will add a parameter thaht do this transformation

    Nicolas
     
  26. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    I was actually going to post on this too. If you had a fast short swipe, but back and forth. I would like to use the speed that we get from startposition to end position. as a value. So basically, the faster your swiped, the greater the value. As an example, imagine swiping (or dragging), back and forth to control the flapping of a bird's wings. The faster your swiped/drag back and forth, the faster/higher the bird would fly. Does that make sense?
     
  27. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi Out2Play,

    Currently you can already do that, with class "Gesture" passed as parameter you have these members :

    * actionTime = Time since the beginning of the gesture

    * deltaTime = Amount of time passed since last change.

    You have to divide the lenght by actionTime or deltaTime to have the swipe speed.

    Nicolas
     
  28. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    Perfect... thanks, Nicolas!
     
  29. CrazyMinnowMichael

    CrazyMinnowMichael

    Joined:
    Jun 4, 2012
    Posts:
    5
    Thank you for the quick response.

    I have performed tests based on your recommendation and found some discrepancies that I hope you can clarify. My tests are not showing the reversed Y coordinates, but what looks like an inaccuracy.

    In this example, the jRect (rectangle) is used to draw the GUI.Button texture and the jumpRect (rectangle) is used in the On_TouchStart in the IsRectUndertTouch and IsInRect methods. The example below puts the jumpRect at precisely the same position as the GUI.Button texture.

    The only difference between the two Rect's is in the Y position where I exclude the controlSize (90) from the Rect used in the IsRectUndertTouch and IsInRect methods. When I include the controlSize, the touch area ends up just above the GUI.Button textures. I can work with it now that I see what its doing, but I'd rather understand it a little better. Thanks again.
    (Screen.height - controlSize - jumpVerticalPadding)
    (Screen.height - jumpVerticalPadding)


    Code (csharp):
    1.  
    2. void OnGUI()
    3. {
    4.     Rect jRect; // Local jump rectangle
    5.     Rect aRect; // Local attack rectangle
    6.     float controlSize = 90;
    7.     float jumpHorizontalPadding = 110;
    8.     float jumpVerticalPadding = 10;
    9.  
    10.     if (guiStyle)
    11.         GUI.skin = guiStyle;
    12.  
    13.     // Local Jump
    14.     jRect = new Rect ((Screen.width - controlSize - jumpHorizontalPadding),
    15.         (Screen.height - controlSize - jumpVerticalPadding),
    16.         controlSize, controlSize);
    17.  
    18.     // jumpRect is a class property translated for touch and used in On_TouchStart
    19.     jumpRect = new Rect ((Screen.width - controlSize - jumpHorizontalPadding),
    20.         (Screen.height - jumpVerticalPadding),
    21.         controlSize, controlSize);
    22.  
    23.     // Jump button
    24.     GUI.Button(jRect, jumpTexture);
    25. }
    26.  
     
  30. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi Outerringz,

    Do you have an example that can you send me, because it isn't really an issue with EasyTouch, but how Unity manage Rect.

    Nicolas
     
  31. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi,

    A new version of EasyTouch EasyJoystick will be available in April

    If you want to discover the new feature of EasyJoystick that will be release on April 2013



    Nicolas
     
  32. Ymmij12

    Ymmij12

    Joined:
    Mar 25, 2013
    Posts:
    2
    Nice work with the easyTouch scripts, it really made the whole control aspect so much better to work with!
    Just one question: Is it possible to use the script for just a button? The closest I've gotten is using GUITexture, which costs a lot of performance.
    With easyTouch, there was no decrease in FPS.
     
  33. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    EasyTouch is a touch screen management library , so you could make buttons as you want. In the next release there will have an option to use EasyTouch with NGUI

    EasyJoystick joystick also uses GUITextures, but I never noticed any performance drops significantly for 3 drawcall and 3 texture.

    I made the choice to use the Unity GUI to not complicate the library and the GUI is 10X faster with Unity 4.X (do not forget to disable the use of the automatic mode of the GUI useGUILayout = false; becarfull after the gui depth won't work) . And also in anticipation of the new GUI will be available with Unity 4.

    After the profiler is misleading, because it can actually show anything like the GUI consumes more than 50% of CPU, but rather than Unity full CPU usage by processes that execute most frequently

    To illustrate what I said look at the two screen...

    My Profiler with Vsync ON

    Vsync = =92% CPU time
    Camera Render = 1.9%
    GUI = 1%



    My Profiler with Vsync off

    Camera Render = 42.2%
    GUI = 18.2%



    Nicolas
     
    Last edited: Mar 25, 2013
  34. Ymmij12

    Ymmij12

    Joined:
    Mar 25, 2013
    Posts:
    2
    thanks for the quick reply:)
     
  35. alfchee

    alfchee

    Joined:
    Jun 14, 2012
    Posts:
    19
    Thanks, this is useful for me too.
    Thanks for the question outtoplay.
     
  36. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    Hello :)

    Awesome package so far!!!

    Is there a js version of the JoystickEvent.cs script available?

    I have an extensive js script to control my character and wanted to add your joystick to it. Not clear how to convert JoystickEvent.cs to js.

    Thanks!
     
  37. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi jococo,

    With EasyJoystick you can choose between C# event or broadcast message thaht works with js

    Nicolas
     
  38. Acenth

    Acenth

    Joined:
    Aug 14, 2012
    Posts:
    42
    When using dynamic joystick, it would be nice if the joystick area wasn't 50% of the screen (Or at least offer Far Left, Far Right). I changed my copy to reflect this, but it'd be great if the option was there by default.

    Awesome tool! Works perfectly!
     
  39. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi Acenth,

    I don't realy undestand what you mean by "50% of the screen (Or at least offer Far Left, Far Right)" My english isn't very good.

    Can you explain more please.
     
  40. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    En mode dynamique, autoriser le déplacement du joystick au delà de la motié de l'écran. Avoir un paramêtre qui permet de définir les limites hautes et basses. Je pense... ;)
     
  41. Acenth

    Acenth

    Joined:
    Aug 14, 2012
    Posts:
    42
    Basically what ZJP said.

    So when Dynamic Joystick is turned on, EasyTouch uses this logic to determine if the joystick should be displayed:

    if (gesture.position.x > Screen.width/2)

    This will show the joystick if I click anywhere on that half of the screen. So if I touch near the middle of the screen, the joystick will show up.

    It would be cool if we could enter a percentage in the inspector to indicate how much of the screen will be usable for the joystick.
     
  42. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    This option already exists, when you select Dynamic Joystick the drop-down list allows you to choose which screen area the joystick can be show.

     
  43. Acenth

    Acenth

    Joined:
    Aug 14, 2012
    Posts:
    42
    I think there is still some confusion (And if I still can't explain it, it's okay because I already changed it in my copy, I just figured other people might like it too).

    So having Top Left/Right and Bottom Left/Right are nice, but I wanted to give players the option to have the joystick anywhere on the far left of the screen, but not so much area that it would be in the center of the screen, where they will be tapping to interact with the game.

    This probably only affects tablet games because the screen is much larger than a phone, so when you are talking about 50% of the screen, it is much more real estate. Most players wont be expecting the joystick to appear basically in the center of the screen on a tablet.

    Here is an example image, with the resolution of an iPad:


     
  44. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    ok, I understood.

    I do not know if I have the time to do that it in this version, because I wanted to release next week, and I still have:
    * A new secret feature to finish
    * And update the documentation
    * And write new example

    But it is a very good feature
     
  45. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Does EasyTouch work on Flash ?
     
  46. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    We just did a test to export out to Flash.

    https://www.dropbox.com/sh/w1grkq1c6vh37u2/wQq5eCPDKX

    Also includes the Generated Actionscript files in the ConvertedDotNetCode folder.

    Platform: Unity pro 4.1.2f , Mac.

    The result looks really good. Most of EasyTouch's functionality work except for Twisting and Pinching.

    Can this be fixed so that all of EasyTouch's functionality work on Flash ?
     
  47. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi Rocki,

    Yes the simulation of the second finger doesn't work with flash. It's very diffcult to me to fixe it, because I haven't flash licence. I need someone that have this licence to work with me.
     
  48. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    I can help. I have flash.
    If you look at the link I sent. It has the Flash Actionscript generated files in the ConvertedDotNetCode folder. This will give you an idea of what is being generated.
     
    Last edited: Apr 4, 2013
  49. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Thank you rocki, it will be easier if you have a skype account.

    I think the bug come from the detection of keydown that notifies the second finger simulation.

    Nicolas
     
  50. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Nicolas,

    I sent my skype info via the forum's messaging system.