# Understanding Input.GetVector when using in 3d movement

4.2.1

### Question

Hello all ,
Im new to godot and 3d , i learn each day something new , i really like to understand what im doing and not just copy paste .
so i saw that also the GODOT template and also few online tutorials are using something like :

``````Vector2 inputDir = Input.GetVector("move_forwards", "move_backwards", "move_left", "move_right");
Vector3 modeDir = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
``````

reading i understand that it is creating 2d vector with negative and positive and related to something that called “Dead zone” .
and then it converted to vector3d .
Does someone knows where i can learn and understand what those 2 lines above does ? tutorials or articles ?
Thanks

Input.GetVector does the linear interpolation between 4 directions for you, it predefines the value along 4 axis like below:

``````createMotionEvent(JoyAxis::JOY_AXIS_LEFT_Y, -1.0f);
createMotionEvent(JoyAxis::JOY_AXIS_LEFT_Y, 1.0f);
createMotionEvent(JoyAxis::JOY_AXIS_LEFT_X, -1.0f);
createMotionEvent(JoyAxis::JOY_AXIS_LEFT_X, 1.0f);
``````

When turning a 2d direction to a 3d direction, it depends on the up direction of your object. The code you exhibit assumes that the up direction is (0, 1, 0). In general case, as you define your own up direction, you should use cross product to calculate your correct 3d direction.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.