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. Hedgehog-Team

    Hedgehog-Team

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

    You can download some javascript example HERE

    I think, that you will find a response at your issue, If this is not the case, make me your problem or send me your example

    Nicolas
     
  2. Frozmat-Games

    Frozmat-Games

    Joined:
    Dec 17, 2012
    Posts:
    25
    Thank you Nicolas.) This is just great! All work fine now.
     
  3. ArcIo

    ArcIo

    Joined:
    Apr 17, 2012
    Posts:
    19
    Ok so I've been using the EasyTouch for a little while now and I'm having an issue with the touch and swipe. Picture a sphere in the center of the screen. My sphere is selectable. When I want to rotate the sphere, I use the swipe to move the sphere. but if I start the swipe by touching the sphere, It selects it.

    What I want is:
    To rotate my sphere by touching dragging my finger anywhere on the screen.
    Tap an item anywhere on the screen to select it.

    Make sense?
     
  4. Hedgehog-Team

    Hedgehog-Team

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

    Easytouch works 2 ways to swipe, depending on if the touch is starting on an object selectable auto or not.

    If your object does not interact directly with the touch, then assign it a layer of collision isn't set in EasyTouch, or no collision layer.
    By cons, if you want your object to interact with the touch, in this case a swipe gesture that starts this object sends DRAG message not a SWIPE message

    So just do the same treatment for SWIPE and DRAG
     
  5. Simplex

    Simplex

    Joined:
    Dec 15, 2012
    Posts:
    15
    Hi,

    I purchased Easy touch a week ago and just going through the documentation Easy Touch 2.3 User Guide, and on page 8 where it asks you to select the pickable layer, where the auto select options are showing the Easy touch ticked options from 1-4, it is not showing on mine when I choose to select it. Can you help? Thanks
     
    Last edited: Dec 21, 2012
  6. Hedgehog-Team

    Hedgehog-Team

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

    First thank you for you purchase, the list of layers pickable show you all the layers that are configured in Unity tagmanager window. These layers belong to the current project and not the imported package



    You must create your own layer, so that you can use. Actually this isn't stated in the documentation, but the layers are a basic functionality of Unity, I thought of not having to explain their operation.


    Nicolas
     
  7. Simplex

    Simplex

    Joined:
    Dec 15, 2012
    Posts:
    15
  8. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Hi,

    I'm a happy user of easytouch but i have a question. I have an object i rotate using a swipe gesture. But i want to have it ease out when i let go of the screen. Do you have an example on how to achieve this with easytouch? I've done this using my own touch controls script without easytouch but i want to use it with easytouch.\

    EDIT:
    And how do i know which direction i'm swiping?
     
    Last edited: Dec 21, 2012
  9. Hedgehog-Team

    Hedgehog-Team

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

    The easiest way is to use ITween library at the swipe end. Something like this...

    Code (csharp):
    1.  
    2. float timeEase =3;
    3.  
    4. void On_SwipeEnd (Gesture gesture){
    5.        
    6.       if (gesture.pickObject == gameObject){
    7.         Hashtable ht= new Hashtable();
    8.                    
    9.         ht.Add("from", transform.eulerAngles.y);
    10.         if (gesture.swipe == EasyTouch.SwipeType.Right){
    11.             ht.Add("to", transform.eulerAngles.y - (gesture.swipeLength * timeEase -gesture.actionTime));
    12.         }
    13.         else{
    14.             ht.Add("to", transform.eulerAngles.y + (gesture.swipeLength* timeEase -gesture.actionTime));
    15.         }
    16.         ht.Add("easetype",iTween.EaseType.easeOutCubic );
    17.         ht.Add("time", timeEase -gesture.actionTime);
    18.         ht.Add("onupdate","On_UpdateItweenSpeed");
    19.         ht.Add("onupdatetarget",gameObject);
    20.         iTween.ValueTo(gameObject,ht);
    21.     }
    22.    }
    23. }
    24.  
    25. void  On_UpdateItweenSpeed(float v){
    26.        transform.eulerAngles = new Vector3(  transform.eulerAngles.x, v,  transform.eulerAngles.z);
    27. }
    28.  
    You can know the direction of swipe with :

    gesture.swipeVector or gesture.swipe (where swipe is an enumeration public enum SwipeType{ None, Left, Right, Up, Down, Other};)
     
    Last edited: Dec 21, 2012
  10. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Thanks for your fast reply! I'm using javascript so i wrote this:
    Code (csharp):
    1.  
    2.  
    3. function On_SwipeEnd(gesture : Gesture)
    4. {
    5.     ht.Add("from", vetPen.transform.eulerAngles.y);
    6.     if(gesture.swipe == EasyTouch.SwipeType.Right)
    7.     {
    8.         ht.Add("to", vetPen.transform.eulerAngles.y - (gesture.swipeLength * timeEase -gesture.actionTime));
    9.     }
    10.    
    11.     if(gesture.swipe == EasyTouch.SwipeType.Left)
    12.     {
    13.         ht.Add("to", vetPen.transform.eulerAngles.y + (gesture.swipeLength * timeEase -gesture.actionTime));
    14.     }
    15.    
    16.     ht.Add("easetype", iTween.EaseType.easeInOutCubic);
    17.     ht.Add("time", timeEase -gesture.actionTime);
    18.     ht.Add("onupdate", "On_UpdateiTweenSpeed");
    19.     ht.Add("onupdatetarget", gameObject);
    20.     ht.Add("islocal", true);
    21.     iTween.ValueTo(vetPen, ht);
    22. }
    23.  
    24. function On_UpdateiTweenSpeed(v : float)
    25. {
    26.     vetPen.transform.eulerAngles = new Vector3(vetPen.transform.eulerAngles.x, v, vetPen.transform.eulerAngles.z);
    27. }
    28.  
    29.  
    My touch script is added to the easytouch gameobject so i can use touch all over the screen. vetPen is the object i want to rotate and then ease out. Thing is, when the iTween updates it goes faster instead of easing out.

    When i didn't use EasyTouch i used this script to detect swipes and taps:
    Code (csharp):
    1.  
    2. #pragma strict
    3. private var vetPen : GameObject;
    4. private var speed = 20f;
    5. private var swiping : boolean = false;
    6. private var touchDeltaPosition : Vector3;
    7. private var cubePosition : Vector3;
    8.  
    9. //Scrolling inertia variables
    10. private var wasRotating : boolean;
    11. private var scrollPosition : Vector2 = Vector2.zero;
    12. private var scrollVelocity : float = 0;
    13. private var timeTouchPhaseEnded : float;
    14. private var inertiaDuration : float = 2.0f;
    15.  
    16. private var itemInertiaDuration : float = 1.0f;
    17. private var itemTimeTouchPhaseEnded : float;
    18. private var rotateVelocityX : float = 0;
    19. private var rotationRate : float = 0.5f;
    20.  
    21. function Awake()
    22. {
    23.     vetPen = GameObject.Find("VetPen");
    24.     cubePosition = vetPen.transform.position;
    25.        
    26. }
    27.  
    28. function Update ()
    29. {
    30.     if(vetPen.transform.position != cubePosition)
    31.         vetPen.transform.position = cubePosition;
    32.  
    33.     if(Input.touchCount == 0)
    34.     {
    35.         swiping = false;
    36.         Inertia();
    37.     }
    38.     else if(Input.touchCount == 1  Input.GetTouch(0).phase == TouchPhase.Began)
    39.     {
    40.         wasRotating = false;
    41.     }
    42.     else if(Input.touchCount == 1  Input.GetTouch(0).phase == TouchPhase.Moved)
    43.     {
    44.         swiping = true;
    45.         wasRotating = true;
    46.         Swiping();
    47.     }
    48.    
    49.    
    50.     if(Input.touchCount == 1  Input.GetTouch(0).phase == TouchPhase.Ended || Input.touchCount == 1  Input.GetTouch(0).phase == TouchPhase.Canceled)
    51.     {
    52.         if(wasRotating)
    53.         {
    54.             if(Mathf.Abs(Input.GetTouch(0).deltaPosition.x) >= 1)
    55.             {
    56.                  rotateVelocityX = Input.GetTouch(0).deltaPosition.x / Input.GetTouch(0).deltaTime;
    57.             }
    58.             itemTimeTouchPhaseEnded = Time.time;
    59.         }
    60.     }
    61. }
    62.  
    63. function Inertia()
    64. {
    65.     if(scrollVelocity != 0.0)
    66.     {
    67.         var t : float = (Time.time - timeTouchPhaseEnded) / inertiaDuration;
    68.         var frameVelocity : float = Mathf.Lerp(scrollVelocity, 0, t);
    69.        
    70.         scrollPosition.x -= frameVelocity * Time.deltaTime;
    71.        
    72.         if(t >= inertiaDuration)
    73.             scrollVelocity = 0.0f;
    74.     }
    75.    
    76.     if(rotateVelocityX != 0.0f)
    77.     {
    78.         var ty : float = (Time.time - itemTimeTouchPhaseEnded) / itemInertiaDuration;
    79.         var XVelocity : float = Mathf.Lerp(rotateVelocityX, 0, ty);
    80.     }
    81.    
    82.     if(ty >= inertiaDuration)
    83.     {
    84.         rotateVelocityX = 0.0f;
    85.     }
    86.    
    87.     vetPen.transform.Rotate(0, -XVelocity * Time.deltaTime * rotationRate, 0);
    88. }
    89.  
    90. function Swiping()
    91. {
    92.     touchDeltaPosition = Input.GetTouch(0).deltaPosition;
    93.     vetPen.transform.Rotate(Vector3.down * touchDeltaPosition.x * Time.deltaTime * speed);
    94. }
    95.  
    96.  
    The inertia function takes makes sure that when the object is rotating it eases out at the end of the touchPhase.
    So did i do something wrong with converting your script to JS?
     
    Last edited: Dec 21, 2012
  11. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    So i fixed the inertia part here's the code:

    Code (csharp):
    1.  
    2. if(Input.touchCount == 0)
    3. {
    4.     Inertia();
    5. }
    6.  
    7. function On_SwipeEnd(gesture : Gesture)
    8. {
    9.     if(Mathf.Abs(gesture.deltaPosition.x) >= 1)
    10.     {
    11.         rotateVelocityX = gesture.deltaPosition.x / gesture.deltaTime;
    12.     }
    13.     itemTimeTouchPhaseEnded = Time.time;
    14. }
    15.  
    16. function Inertia()
    17. {
    18.     if(scrollVelocity != 0.0)
    19.     {
    20.         var t : float = (Time.time - timeTouchPhaseEnded) / inertiaDuration;
    21.         var frameVelocity : float = Mathf.Lerp(scrollVelocity, 0, t);
    22.        
    23.         scrollPosition.x -= frameVelocity * Time.deltaTime;
    24.        
    25.         if(t >= inertiaDuration)
    26.             scrollVelocity = 0.0f;
    27.     }
    28.    
    29.     if(rotateVelocityX != 0.0f)
    30.     {
    31.         var ty : float = (Time.time - itemTimeTouchPhaseEnded) / inertiaDuration;
    32.         var XVelocity : float = Mathf.Lerp(rotateVelocityX, 0, ty);
    33.     }
    34.    
    35.     if(ty >= inertiaDuration)
    36.         rotateVelocityX = 0.0f;
    37.        
    38.     vetPen.transform.Rotate(0, -XVelocity * Time.deltaTime * rotationRate, 0);
    39. }
    40.  
    So that works perfect :) the only thing is i can't get the swipe right. When i swipe left the item rotates right and when i swipe right the item rotates left. I think it's a simple thing but i can't get it right.

    Here's the swipe gesture code:
    Code (csharp):
    1.  
    2.     if(gesture.swipe == EasyTouch.SwipeType.Left)
    3.     {
    4.         vetPen.transform.Rotate(new Vector3(0, 1, 0) * gesture.deltaPosition.x * Time.deltaTime * speed);
    5.     }
    6.    
    7.     if(gesture.swipe == EasyTouch.SwipeType.Right)
    8.     {
    9.         vetPen.transform.Rotate(new Vector3(0, 1, 0) * gesture.deltaPosition.x * Time.deltaTime * speed);
    10.     }
    11.  
    12.     if(EasyTouch.SwipeType.Up || EasyTouch.SwipeType.Down)
    13.     {
    14.         vetPen.transform.Rotate(new Vector3(0, 0, 1) * gesture.deltaPosition.y * Time.deltaTime * speed);
    15.     }
    16.  
     
  12. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Good.

    You have juste to multiply the by -1 the delta position or change your Vector3 (Vector3(0,1,0) and Vector3(0,-1,0)

    All it's possible and easy with Easytouch :;)
     
    Last edited: Dec 23, 2012
  13. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Thx that worked :) Silly of me i didn't see that one :p thx again for the fast reply
     
  14. milox777

    milox777

    Joined:
    Sep 23, 2012
    Posts:
    195
    I can't seem to get the EasyJoystick work simultaneously with swipe using EasyTouch (I used swipe method from examples provided with the plugin) - when I move the joystick the swipe is being registered as well. In my game I want joystick controls for the player and swipe based combat - so you move the character with a joystick (on the left side of the screen) and you can attack using swipe gestures at the same time on the right side of the screen. Is it possible to do this with EasyTouch? Any help appreciated.
     
  15. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Of course you can, but it is up to you to control the swipe for the attack is well in the right side of the screen.

    To do this, you have "startposition" and "position" members of the Gesture class when you receive the swipe.

    Nicolas
     
  16. Simplex

    Simplex

    Joined:
    Dec 15, 2012
    Posts:
    15
    Hi Nicolas,

    Im just in the process of still getting started with easy touch.

    I have problem with the following code, which is for the simple tap.

    // Subscribe to events
    void OnEnable(){
    EasyTouch.On_SimpleTap += On_SimpleTap;
    }

    void OnDisable(){
    UnsubscribeEvent();

    }

    void OnDestroy(){
    UnsubscribeEvent();
    }

    void UnsubscribeEvent(){
    EasyTouch.On_SimpleTap -= On_SimpleTap;
    }

    // Simple tap
    private void On_SimpleTap( Gesture gesture){

    // Verification that the action on the object
    if (gesture.pickObject == gameObject){
    gameObject.renderer.material.color = new Color( Random.Range(0.0f,1.0f), Random.Range(0.0f,1.0f), Random.Range(0.0f,1.0f));
    }
    }

    I have created a sphere and added the above code to a c# script and assigned the appropriate layer.

    The sphere does not change colour at all if I tap on the sphere or on anywhere on the iPhone 4.

    If I remove the if statement "if (gesture.pickObject == gameObject) " part , then it does change colour regardless of whether the gesture is tapped on the sphere or anywhere of the screen. I think there is a problem with the gesture.pickObject == gameObject condition, If Im mistaken. Can you please help. Thanks
     
  17. Hedgehog-Team

    Hedgehog-Team

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

    Is that your code works in Unity before testing on iPhone 4 ?

    When you remove the condition, it is normal that the sphere changes color because the message will be received irrespective of the place where you touch the screen.

    Possible causes:
    * The layer is not set correctly in the tagmanager
    * The layer is not assigned to EasyTouch
    * The camera does not have the tag MainCamera

    However, if everything is correct could you send to me the package of scene , so I can see what's wrong at mail : the.hedgehog.team@gmail.com
     
  18. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Hi,

    What's the best way to get Pinch to zoom working with vertical panning? I find this a hard one to do so maybe you have some examples or ideas how to fix this?
     
  19. Hedgehog-Team

    Hedgehog-Team

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

    Have you tried as in the example image manipulation?

    Nicolas
     
  20. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Yes i'm implementing it as we speak in my own project. But it doesn't have vertical panning :(
     
  21. Hedgehog-Team

    Hedgehog-Team

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

    Can you send to me, your example ?
     
  22. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Sure here is the whole script.
    Now i'm still experimenting with the Pinch_In and out so there maybe something not working at the moment.

    Code (csharp):
    1.  
    2. #pragma strict
    3. private var hit : RaycastHit;
    4. private var ray : Ray;
    5. private var mainCam : GameObject;
    6.  
    7. private var human : GameObject;
    8. private var speed : float = 20f;
    9.  
    10. //Inertia Variables
    11. private var rotateVelocityX : float = 0;
    12. private var itemTimeTouchPhaseEnded : float;
    13. private var timeTouchPhaseEnded : float;
    14. private var inertiaDuration : float = 2.0f;
    15. private var scrollVelocity : float = 0;
    16. private var scrollPosition : Vector2 = Vector2.zero;
    17. private var rotationRate : float = 0.5f;
    18.  
    19. function Awake()
    20. {
    21.     human = GameObject.Find("Human");
    22.     mainCam = GameObject.Find("Main Camera");
    23. }
    24.  
    25. function Update()
    26. {
    27.     if(Input.touchCount == 0)
    28.     {
    29.         Inertia();
    30.     }
    31. }
    32.  
    33. function On_SimpleTap(gesture : Gesture)
    34. {
    35.     if(Physics.Raycast(ray, hit))
    36.     {
    37.         if(!iGUICode_app480x320.getInstance().isEnabled)
    38.         {
    39.             if(hit.collider.name != "MenuCollider")
    40.                 ClickManager4G.CM.Clicked(hit.collider.name);
    41.         }
    42.     }
    43.    
    44. }
    45.  
    46. function On_Swipe(gesture : Gesture)
    47. {
    48.     if(EasyTouch.SwipeType.Left || EasyTouch.SwipeType.Right)
    49.     {
    50.         human.transform.Rotate(Vector3.down * gesture.deltaPosition.x * Time.deltaTime * speed);
    51.     }
    52. }
    53.  
    54. function On_SwipeEnd(gesture : Gesture)
    55. {
    56.     if(EasyTouch.SwipeType.Left || EasyTouch.SwipeType.Right)
    57.     {
    58.         if(Mathf.Abs(gesture.deltaPosition.x) >= 1)
    59.         {
    60.             rotateVelocityX = gesture.deltaPosition.x / gesture.deltaTime;
    61.         }
    62.         itemTimeTouchPhaseEnded = Time.time;
    63.     }
    64. }
    65.  
    66. function On_PinchIn(gesture : Gesture)
    67. {
    68.     var zoom : float = Time.deltaTime * gesture.deltaPinch / 25;
    69.     var scale : Vector3 = mainCam.camera.transform.localScale;
    70.    
    71.     if(scale.x - zoom > 0.1)
    72.         mainCam.camera.transform.localScale = new Vector3(scale.x - zoom, scale.y - zoom, 1f);
    73.    
    74. }
    75.  
    76. function On_PinchOut(gesture : Gesture)
    77. {
    78.     var zoom : float = Time.deltaTime * gesture.deltaPinch / 25;
    79.     var scale : Vector3 = mainCam.camera.transform.localScale;
    80.    
    81.     if(scale.x - zoom > 0.1)
    82.         mainCam.camera.transform.localScale = new Vector3(scale.x + zoom, scale.y + zoom, 1f);
    83. }
    84.  
    85. function Inertia()
    86. {
    87.     if(scrollVelocity != 0.0)
    88.     {
    89.         var t : float = (Time.time - timeTouchPhaseEnded) / inertiaDuration;
    90.         var frameVelocity : float = Mathf.Lerp(scrollVelocity, 0, t);
    91.        
    92.         scrollPosition.x -= frameVelocity * Time.deltaTime;
    93.        
    94.         if(t >= inertiaDuration)
    95.             scrollVelocity = 0.0f;
    96.     }
    97.    
    98.     if(rotateVelocityX != 0.0f)
    99.     {
    100.         var ty : float = (Time.time - itemTimeTouchPhaseEnded) / inertiaDuration;
    101.         var XVelocity : float = Mathf.Lerp(rotateVelocityX, 0, ty);
    102.     }
    103.    
    104.     if(ty >= inertiaDuration)
    105.     {
    106.         rotateVelocityX = 0.0f;
    107.     }
    108.    
    109.     human.transform.Rotate(0, -XVelocity * Time.deltaTime * rotationRate, 0);
    110. }
    111.  
    Also if you have time, could you take a look at my simpleTap function? I'm using raycast here but it's not working for me. Is there an EasyTouch function available to do the same thing i'm trying to do with raycasting?
     
  23. Hedgehog-Team

    Hedgehog-Team

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


    To zoom:
    Can you tell me what does not work, if it's easy touch or if you do manage to get the result you want.

    To Tap
    Why do you a raycast, EasyTouch can do it for you with auto-selection ?
     
  24. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Hi,

    The zoom function doesn't work at all on the iPod Touch 4th Gen. And on my Mac i don't know which key to press to get the second finger. For the tap function, i forgot about that ^^ implementing it now :)
     
  25. Hedgehog-Team

    Hedgehog-Team

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

    For the simulation of the second finger, use the Ctrl or Alt.

    I don't know if Unity supports multi-touch on IPOD, can you make a code that displays anything in receiving events Pinch ...
     
  26. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Well i know for sure that it does support multi-touch. The zoom function isn't working on my Mac too.
     
  27. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    It doesn't work or you do not get the messages?
     
  28. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    I get the debug logs in the Pinch_In and Pinch_Out function but it's not zooming :(
     
  29. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    This is normal, because I'm looking at your code, you do a scale on the camera. A scale on the camera doesn't zoom.

    Either you have to influence the Z position , or the field of view
     
  30. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    True so i have added this. It's zooming now but it goes crazy when zooming, way to sensitive.

    Code (csharp):
    1.  
    2. function On_PinchIn(gesture : Gesture)
    3. {
    4.     Debug.Log("PinchIn" + "fov : " + AnimationScript4G.AS.retFOV());
    5.     selectedCamera.fieldOfView = Mathf.Clamp(selectedCamera.fieldOfView + (1 * zoomSpeed), AnimationScript4G.AS.retFOV(), 60);
    6.    
    7. }
    8.  
    9. function On_PinchOut(gesture : Gesture)
    10. {
    11.     Debug.Log("PinchOut");
    12.     selectedCamera.fieldOfView = Mathf.Clamp(selectedCamera.fieldOfView - (1 * zoomSpeed), AnimationScript4G.AS.retFOV(), 60);
    13. }
    14.  
     
  31. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    I think it is better to change the position of the camera

    With something like this :

    Code (csharp):
    1. function On_PinchIn(gesture : Gesture){
    2.            float zoom = Time.deltaTime * gesture.deltaPinch/25;
    3.            selectedCamera.transform.Translate( Vector3.forward * zoom)
    4. }
    5.  
    6. function On_PinchOut(gesture : Gesture){
    7.            float zoom = Time.deltaTime * gesture.deltaPinch/25;
    8.            selectedCamera.transform.Translate( Vector3.forward * -zoom)
    9. }
     
  32. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Thx that worked :) do you have any idea how to do the panning? So when i start to pinch zoom on a position on the screen the camera zooms to the position i started to pinch zoom?
     
  33. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    I'm guessing you don't know how to do this ^^ since there is no reply from you...
     
  34. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    I guess you calculate an offset displacement of the image depending on the starting point and current gesture time
     
  35. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    429
    This is a great bit of kit but one major annoyance for me is being unable to register a swipe when the motion begins on an object set to the autodetect layer.

    I.e: move forward = swipe up, interact = tap

    but starting a swipe when the interactable object is in front means it won't work
     
  36. Hedgehog-Team

    Hedgehog-Team

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

    Can you explain in more detail what you want to do ?

    When you start a swape to autodetect layer, it's send Drag Event, it's like a swipe but you know it'over an object.
    You have to do the same thing into Drag and Swipe events
     
    Last edited: Jan 5, 2013
  37. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    429
    Hedgehog Team,

    To explain it in more detail, the player navigates the scene by swiping.

    There are interactive elements in the scene, if they get caught during the start of the swipe, the swipe doesn't register.

    If I understand you correctly, you're saying I need to change this from a swipe gesture to a drag-based event?

    What's the simplest way to go about this? I'm pulling the swipe directions from the example one finger swipe.js in the original versions.

    p.s: In this new version, one finger events don't seem to register in the editor, no trail showing motion of the drag etc...It works for two finger events. Strange.
     
  38. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Yes, you can do something like this , if you don"t need drag events on autoselect layer

    Code (csharp):
    1. private void On_Drag(Gesture gesture){
    2.      On_Swipe(gesture);
    3. }
    4. private void On_Swipe(Gesture gesture){
    5.        
    6.    ......
    7. }
    After you can do this for On_DragStart On_DragEnd ...


    The one finger example doesn't work because I forgot to remove Enable Unity Remote... Remove it in the inspector and the example is going to work
     
  39. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    429
    That worked perfectly, many thanks!

    Fantastic product.
     
  40. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Hi, I bought this really Excellent Package and beginning to convert my old code to easytouch.

    I have this code snippet that detects mouse input and makes an intersection with a plane. What is your recommended way of converting this code to use with EasyTouch.

    Ray ray= Camera.main.ScreenPointToRay (Input.mousePosition);
    _selectedObject= GC.getSelectedObject();

    plane = new Plane(Vector3.forward, GC.transform.position);
    hitDistance = 0;
    if(plane.Raycast(ray, out hitDistance)){
    _currIntersectPosition = GetIntersectPoint(hitDistance, ray);

    if(_lastIntersectPosition != Vector3.zero){
    _translationDelta = _currIntersectPosition - _lastIntersectPosition;


    Thanks
     
  41. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Hedgehog Team,

    I have this code: _ray= Camera.main.ScreenPointToRay (Input.mousePosition);

    I tried converting to EasyTouch with:

    Vector3 position = _gesture.GetTouchToWordlPoint(1);
    _ray= Camera.main.ScreenPointToRay (position);

    The movement is very small and does not work like the original code.

    Can you see where I am going wrong.

    Thanks in advance.
     
  42. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Oh, found the answer to the last post.

    _ray= Camera.main.ScreenPointToRay (_gesture.position);
     
  43. milox777

    milox777

    Joined:
    Sep 23, 2012
    Posts:
    195
    I wonder, if there's any easy way to clamp the values affected by Joystick? Say you have joystick that rotates the camera up and down, but you don't want to rotate the whole thing in 360 degrees, stop it when it reaches a specified angle value. In standard unity code we have Mathf.Clamp but that requires putting in FixedUpdate to make it smooth, not sure how that would work with EasyJoystick events?
     
  44. Hedgehog-Team

    Hedgehog-Team

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

    Direct mode allows you to rapidly prototype, However, if you want more control, you must switch to event or include mode.

    With event mode you go to receive an event whenever the joystick is pressed. This event will have a class with different values ​​for each axis of the joystick. ust after you create your own management of movement and clamp, as you would with the Input class.

    Nicolas
     
  45. dev01

    dev01

    Joined:
    May 3, 2010
    Posts:
    21
    I want to raycast to surface normals and rotate character controller to match surface underneath( like a skateboard ramp) and implement easy touch buttons to jump and do tricks etc. I cant seem to find any answers on hoe to do this with EasyJoystick or EasyTouch. can someone direct me to a script or example.
     
  46. Hedgehog-Team

    Hedgehog-Team

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

    This is not really related to EasyTouch and EasyJoystic, but more general programming with Unity, but I'll try to answer.

    How to create a button :
    - You can do like in "Game controller" example
    - Or just show a GUITexture and test if the touch is under the rect of this texture.

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Button : MonoBehaviour {
    5.    
    6.     public Texture2D buttonTexture;
    7.    
    8.     public float screenHeight;
    9.    
    10.     void OnEnable(){
    11.         EasyTouch.On_TouchStart += On_TouchStart;
    12.     }
    13.  
    14.     void OnDisable(){
    15.         EasyTouch.On_TouchStart -= On_TouchStart;
    16.     }
    17.    
    18.     void OnDestroy(){
    19.         EasyTouch.On_TouchStart -= On_TouchStart;
    20.     }
    21.    
    22.     void OnGUI(){
    23.         GUI.DrawTexture( new Rect(200,200,100,100),buttonTexture);
    24.         screenHeight = Screen.height;
    25.     }
    26.    
    27.     void On_TouchStart(Gesture gesture){
    28.    
    29.         if (gesture.IsInRect( new Rect(200,screenHeight-(200+100),100,100))){
    30.             Debug.Log ("Button ok");   
    31.         }
    32.     }
    33. }
    How to match surface

    Just attach this script to you gameobject

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class MatchSurface : MonoBehaviour {
    5.    
    6.     // Update is called once per frame
    7.     void Update () {
    8.        
    9.         RaycastHit hitInfo;
    10.            
    11.         if (Physics.Raycast( transform.position , Vector3.down, out hitInfo)){
    12.            
    13.             transform.rotation = Quaternion.Euler( new Vector3(0,transform.rotation.eulerAngles.y,0));
    14.             transform.rotation = transform.rotation * Quaternion.FromToRotation(Vector3.up, hitInfo.normal);    
    15.         }          
    16.     }
    17. }
     
  47. kmgilbert100

    kmgilbert100

    Joined:
    Sep 6, 2011
    Posts:
    255
    could a jump button be programmed in? if so im sold
     
  48. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Yes, of course, you can do you what you want

    Let's have a look at our Controller Demo, in the web player :HERE
     
  49. kmgilbert100

    kmgilbert100

    Joined:
    Sep 6, 2011
    Posts:
    255
    i dont see a 3rd person jump example? any way u could whip me up one?
     
  50. dev01

    dev01

    Joined:
    May 3, 2010
    Posts:
    21
    I have Move-Turn_Jotstick turning and moving on same joystick with banking animations for left and right...when I add this script to my game object that is parented to my character controller nothing happens as far as rotation up a ramp going in the (y axis for transform z) but sideways rotation gets skewed after script is added. I even tried to put an empty game object with this script on the front of the skateboard with no results. I can try something else. Is there any documentation I could look at for EasyJoytick?