+1 vote

I saw this code at docs:

``````...
dir = Vector3()
...
input_movement_vector = input_movement_vector.normalized()
dir += -cam_xform.basis.z.normalized() * input_movement_vector.y
...
``````

Why can the product of input_movement_vector.y and cam_xform.basis.z be assigned(+=) to vector dir?
And, why can cam_xform.basis.z.normalized() be used? I saw *kidscancode* said “you can't normalize only the x component”.
I can't understand that.

in Engine

You need to learn about vectors and transforms.

First, I would really recommend reading this:
https://docs.godotengine.org/en/latest/tutorials/math/vector_math.html

And then this:
http://kidscancode.org/godot_recipes/math/transforms/

"Normalizing" means setting a vector's length to `1`.

`transform.basis` is made up of three vectors, `x`, `y`, and `z`, which represent the object's local coordinate axes. So `basis.z` is a Vector3. See Transform for details.

That said, basis vectors are already normalized, so it's not necessary to use `normalized()` on them.

by (21,967 points)
selected by