# How to move Character with left joystick of a controller

Hi, I’m a beginner on Armory3D and I want my character to move using the left joystick. I tried with the Logic Node Gamepad Stick but it has a lot of bugs. I am trying with Logic Gamepad Coord and with Logic Node Math and Translate Object but when I run the game in Armory Player the character still does not move. Here is an image of the Logic Nodes I used.

First, try not to multiply by 0.000.

2 Likes

Ok I understood I added as value 0.6 to value 1 and it works. On the other hand, the cube always moves a little bit when I let go of the left analog stick.

Unless your character physics is causing it to move (i.e. you’re on a hill/slope), you might need to implement some threshold when you retrieve your gamepad’s, joystick coordinates. FYI, joystick is almost always an issue when making your own joystick controls in any game-engine/software (it’s not a bug), as different controllers/software use different sensitivity rates, so it’s usually left to the developer to implement/adjust it. Sensitivity that seems too high on one device may be too low on another, and vice-versa, so it’s usually recommended to allow the user/player to allow customizeation of the joystick thresholds manually, through provided settings.

I haven’t put any physics in my demo yet. How do you adjust the sensitivity threshold?

You’ll need to implement the threshold yourself, by checking if the gamepad coordinates are `equal or greater than` or `equal or lesser` than a certain value.

With which Logic Nodes to use to know which if the gamepad coordinates are equal are equal or greater than or equal or lesser?

I’m not 100% sure (Because math isn’t my best skill), but I believe the Gate node would do this?

I don’t really know how to do with the Gate node.

The `Left Stick` output of the `Gamepad Coords` node returns a vector whose x/y coordinates correspond to the x/y displacement of the gamepad stick. What you did in your screenshot is to compare whether the x coordinate is larger than the y coordinate, so the output is `True` when the stick is displaced further to the right than it is displaced to the top, which is most likely not what you want.

You can implement the threshold proposed by @ RPaladin by comparing the length of the stick’s displacement vector. It should work like this (untested):

Just make sure that you choose a small enough positive threshold, the length of a vector is never negative and if the threshold is too large it will never be “reached”. Just experiment with different values and maybe print the output of `Left Stick` or `Length` to the console to see how large the values actually are.

By using a length-based threshold you ensure that the threshold works independent of the direction in which the stick is displaced. If you were using a threshold vector instead (e.g. checking whether the displacement is greater than `[0.1, 0.1, 0.0]`), you’d need to move the stick stronger diagonally to reach the threshold than when you’d move it in one of the axis directions.

2 Likes

What Logic Node did you use for Logic Node TV: Threshold?

Hi, it is a Tree Variable node created from a float node.

3 Likes

I managed to create the TV: Threshold variable with the Node. Thank you very much for your help!

I made the exact same Node Tree as shown in your picture and it works. On the other hand the only concern is that the joystick is much too sensitive. Personally, I work on Armory with an Xbox Series controller.

You can scale the `Left Stick` vector value by using the `Multiply (Floats)` mode of the `Vector Math` node:

A sensitivity between 0 and 1 will make the movement slower, a sensitivity > 1 will make it stronger.

You don’t need to use tree variables for sensitivity and threshold values (you can use a plain `Float` node or simply enter the sensitivity value in the input socket), but I used them to make it easier to see what the value is used for. Also, using tree variables you can easily manipulate the sensitivity in other parts of the logic node if you want. As @ RPalain already wrote, it probably makes sense to let the user player the sensitivity

However, there is still the same problem. The character represented by a cube in my example always moves a little bit when the joystick is in the center.

Hol’ up. What’s with the “Left Movement”/“Right Movement” outputs? Is that supposed to refer to the D-Pad or another set of buttons?

Did you combine both threshold and sensitivity? If so, are you sure that the slight movement comes from the controller? Check what position/movement values the stick outputs (you can use the `Print` node for this) and whether the movement also happens if you disable the controller trait. If the cube still moves it could be caused by some physics stuff for example.

`[Left/Right] Stick` is the position of the sticks, `Left/Right Movement` is the change in position of the sticks. It’s like mouse position vs. mouse movement (delta), position vs. velocity.

Do you think naming the outputs `Left/Right Stick Position` and `Left/Right Stick Movement` would be better?

Ah, thank you. That does sound potentially very useful. The outputs should, in my opinion, should be renamed for clarity. Perhaps saying Left/Right Stick Delta would be better, since it is more accurate. Calling it “movement” might make it friendlier to lay people, but could also bring more confusion than using more technically-oriented terminology. Idk. There are advantages and disadvantages to both.

Indeed there seems to be a bug with the Logic Node Gamepad Sticks. The down and right direction does not work and the up direction is mapped to the analog stick down direction. Also it depends on the controller used for the node tree that timodriaan and RPaladin gave me. With an Xbox Series controller the cube tends to move slightly even if I don’t press the stick. On the other hand, with an Xbox 360 controller, the cube remains motionless when I don’t press the stick. Maybe Armory3D has a different way of recognizing controllers.