Joystick triggers directed function

I started learning about virtual joysticks today and I have question about triggering actions with them. For example I want to trigger action(e.g roll) towards the direction of stick, if I exceed the value of axis(1 or -1). How would I do that?

Hello conguerror,

I’m a niewbie in unity but i think you can use “touchDeltaPosition”.
exemple (I haven’t tested this script, it just serves as an idea.) :

 public Vector2 startPos;
 public Vector2 direction;
 public float direction;

 void Update()
 {
        if (Input.touchCount >0 && Input.GetTouch (0).phase == TouchPhase.Began) 
         {
                Touch touch = Input.GetTouch(0);
                 startPos = touch.position;
          }
             if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
             {
                 direction = touch.position - startPos;
             }
           if (direction > /*your value*/)
           {
           /*your action*/
           }
}

You can find documentation for touch phase here TouchPhase.Began.
If you put the localization of your joystick, and you use the “touchDeltaPosition”, i think you can do what you want.
Hope this answer can help you.
Regards