I think I see why you're confused, and I can't blame you.
basis
describes a 3d space and has 3 unit vectors. Those are confusingly named x, y and z. IMO they should have been named something like right
, up
and forward
, because each of those is a Vector3, not a float.
The input object looks like a Vector2. So it would look something like: { x: 1.0, y: -0.5 }
In this example, the user is pressing full right and half down on the joystick.
But the basis
object looks like this:
{
x: {
x: 1.0,
y: 0.0,
z: 0.0
},
y: {
x: 0.0,
y: 1.0,
z: 0.0
},
z: {
x: 0.0,
y: 0.0,
z: 1.0
}
}
Source: https://docs.godotengine.org/en/stable/classes/class_basis.html#class-basis
See what I mean when I say the naming of the unit vectors is confusing? To get the z
component of the forward vector you must write: basis.z.z
But the basis I shown is just the identity, meaning it's equal to the "normal" axes. The basis is used also to represent rotation. So I was wrong when I said basis.z * input.y
is useless, since if the camera is rotated it won't result in 0 all the time.
See these pages if you need a refresher on vectors and bases: https://docs.godotengine.org/en/stable/tutorials/math/vector_math.html
https://docs.godotengine.org/en/stable/tutorials/math/matrices_and_transforms.html#basis-of-the-transformation-matrix