News: Enjoy our Christmas offer 30% off on our latest package Tower Defense Level Kit http://u3d.as/m7h

  • August 18, 2018, 04:42:11 AM

Login with username, password and session length

Author Topic: !!!!!!!!Cant get respond from Nicolas!!!!!!!!!!!!!  (Read 755 times)

Offline elvess

  • Newbie
  • *
  • Posts: 7
!!!!!!!!Cant get respond from Nicolas!!!!!!!!!!!!!
« on: July 07, 2017, 05:32:54 PM »
Hello Nicolas.
Ive wrote U private message near two weeks ago about changing joystick's behaviour and still didnt get respond.

Would U like to be so kind to write some words about my question cause we dont have time and if its not possible to implement
we are going to find another way. But we need to now it

Thank U
Paul

Offline Nicolas

  • Administrator
  • Hero Member
  • *****
  • Posts: 792
Re: !!!!!!!!Cant get respond from Nicolas!!!!!!!!!!!!!
« Reply #1 on: July 08, 2017, 12:40:14 PM »
Hi,

I'm really sorry for that, could you ask your question here, because I can not find an email about a joystick.

Nicolas

Offline elvess

  • Newbie
  • *
  • Posts: 7
Re: !!!!!!!!Cant get respond from Nicolas!!!!!!!!!!!!!
« Reply #2 on: July 10, 2017, 12:27:19 PM »
Sure.
We are making MOBA game and currently found a lack of joystick functionality.
We have dynamic joystick. When player make a tap joystick appears in tap position. Than player swipe the finger, for example, in left side. Joystick returns (1, 0) direction. But when player wants to get (-1, 0) direction he has to swipe his finger right till tap position and only after passing tap position he will get (-1, 0). Its cause some kind of lack of sensitivity in our game. Our desired behavior is something like axis-based direction but for joystick or something like Your touchpad works. When joystick is in the right corner of the screen and player's finger is in the left corner and player wants to move right he just swipe in the right side and gets right direction, but not turning back finger to joystick position.

Ive tried to draw schematic image of what we need. Link: https://app.box.com/s/2tgswxwcb8b8ekuifuqg272rc1c8pcir
Couldn't upload by reply form.

Is it possible to add some code to get such behavior? Or its necessary to do a lot of work to reach the result?

Paul,
LoadMe.

Offline Nicolas

  • Administrator
  • Hero Member
  • *****
  • Posts: 792
Re: !!!!!!!!Cant get respond from Nicolas!!!!!!!!!!!!!
« Reply #3 on: July 10, 2017, 02:07:53 PM »
Hi,

Indeed it is not too much the behavior of a joystick, because what interests you is more the direction than the position of the thumb.

You can do this behavior with the touch pad as you say, but I suppose you want the graphical aspect of the joystick. The problem is the value of the joystick is calculated according to a position, not a movement.

- The first solution would be to compare the current value  and the previous one. If the current value is greater than 0 and the old value is less then the current value we go to right etc....

- The second solution would be to use the touch pad, and with script to manage the display of a thumb relative to the touchpad events
« Last Edit: July 10, 2017, 02:10:08 PM by Nicolas »

Offline elvess

  • Newbie
  • *
  • Posts: 7
Re: !!!!!!!!Cant get respond from Nicolas!!!!!!!!!!!!!
« Reply #4 on: July 10, 2017, 02:55:18 PM »
I tried to use touchpad but it gives little bit wrong direction. As far as I understand joystick gives direction relative to its center (like arrows of a clock). Touchpad instead gives global direction which brings more sharp movements. So the only way is to rewrite joystick somehow.

I have a small misunderstanding about the way U suggest to compare current and previous values. Would U like to be so kind to explain more detailed?

Offline elvess

  • Newbie
  • *
  • Posts: 7
Re: !!!!!!!!Cant get respond from Nicolas!!!!!!!!!!!!!
« Reply #5 on: July 10, 2017, 02:56:52 PM »
Id like to add that graphical aspect of the joystick is not the point for us because thumb is hidden.

Offline Nicolas

  • Administrator
  • Hero Member
  • *****
  • Posts: 792
Re: !!!!!!!!Cant get respond from Nicolas!!!!!!!!!!!!!
« Reply #6 on: July 11, 2017, 12:25:00 PM »
Compared to what you describe, it is not the position of the joystick that is important, but its direction. It is therefore sufficient to compare the current value with the previous one to deduce the direction, and taking into account the sign of values.

The only problem is that a joystick has progressive values, calculate between the center and the edge. By doing what you want, there will no longer be progressivity. For when you are right to the maximum and you go left, what value should be the joystick?

So we are on a system on OFF 1 or 0, I go left, or I go right, but not I go slowly to the left etc ..







Offline elvess

  • Newbie
  • *
  • Posts: 7
Re: !!!!!!!!Cant get respond from Nicolas!!!!!!!!!!!!!
« Reply #7 on: July 11, 2017, 05:48:06 PM »
Thats right what we need. There is no joystick-depended move speed in our game. Only the direction along x and y axis: (1,0) (0.7,0.7) etc.

Sorry but I still don't understand quite enough about comparing U suggest. Compare current value with the previous one - Where should I implement it? In ETCJoystick script or in OnJoystickMove(Vector2) handler? What actually "current value" is? Is it a direction returned by joystick or eventData.position inside ETCJoystick calculations or maybe something else. 

Offline Nicolas

  • Administrator
  • Hero Member
  • *****
  • Posts: 792
Re: !!!!!!!!Cant get respond from Nicolas!!!!!!!!!!!!!
« Reply #8 on: July 13, 2017, 07:45:48 AM »
As you know, you have several methods to get the values of the joystick.

To do what I describe, you have to use the events of the joystick, calling a script from the joystick inspector.

1- Create a new Scene

2- Add a joystick

3- Create this new script, this one processes the values sent by the joystick to format it as you wish (I made you the X axis, you have to do for the Y axis).

Code: [Select]
public class MyJoystickBehavior : MonoBehaviour {

    private Vector2 oldJoystickValue;
    private Vector2 joystickNewValue;

    void Start () {
        oldJoystickValue = Vector2.zero;
        joystickNewValue = Vector2.zero;
    }

    public void OnJoystickMove(Vector2 move)
    {
       

        // Right direction
        if (move.x > 0 && (move.x > oldJoystickValue.x))
        {
            joystickNewValue.x = 1;
        }


        if (move.x < 0 && (move.x > oldJoystickValue.x))
        {
            joystickNewValue.x = 1;
        }


        // Left value
        if (move.x > 0 && (move.x < oldJoystickValue.x))
        {
            joystickNewValue.x = -1;
        }

        if (move.x < 0 && (move.x < oldJoystickValue.x))
        {
            joystickNewValue.x = -1;
        }

        if (move.x == 0 )
        {
            joystickNewValue.x = 0;
        }

        oldJoystickValue = move;

        Debug.Log(joystickNewValue);


        // Do the same thing for Y axis
       
    }

4- Drag 'n drop this script on a game object, and call it from the joystick inspector on Move Event



5- Launch and look at the console