What does adding vector 3 to lookvector mean?

game.Workspace.cam.CFrame.LookVector + distancefromcam

whats does this mean

I always do LookVector * 15 (number)

But what is adding to a look vector i know its not used much and its complex but its used in many scripts I found

Look Vector is the way in which an object is facing. If say I added a bodyvelocity and told it to add velocity to the parts lookvector. It would be adding velocity in the direction of which the part is facing. In this case it looks as if the code is getting the direction in which the camera is facing, then adding a variable to that result.

1 Like

Well a more general question would be “what does it mean to add up vectors?”.
you see, think of a vector as an arrow in space pointing in certain direction, and each component (x, y, z) as values of how much the arrow should point in each direction. Now when you add two vectors together, your essentially increasing or decreasing how much the resulting vector points in different direction… Lets take a case where you have two vectors,
A = Vector2.new(0, 5), B = Vector2.new(0, -2)
To visualize the 2D vectors above for you, think of VectorA as an arrow stemming from the origin and to the RIGHT 5 units, and VectorB also as an arrow stemming from the origin and going to the LEFT 2 units.

Now Imagine the vectors were some sort of guiding system taking you to a place. The system gives you vectorA and VectorB, meaning that you would walk 5 units to the Right, then walk 2 Units to Left, in total that would be walking (5 + -2) = 3 units. Because the effect of Walking to right 5 units, then walking left 2 units subtracts the 2 from the 5 units that you’ve already walked. if vectorB was (0, 5), you would end back at (0,0);

so now to your question, what does it mean to add LookVector and another vector? well remember, a LookVector is just a regular vector, what makes it special is that its a unit vector, meaning that the arrow that it makes has a length of just 1 stud. So when you another vector to it, its just adding to any other vectors. The new vector that you get will depend on the components of the two vectors that your adding together;

example:

local v = Vector2.new(-3, 2)–looking 3 units down, and to the right 2 units;
local v2 = Vector2.new(3, -2); --looking 3 units up, and to the left 2 units;
local sum = (v + v2)–will output Vector2.new(0,0)

1 Like

Yes thank you both for answering but the question is why you need to add 2 vector in this script?

game.Workspace.cam.CFrame.LookVector + distancefromcam

It says look vector, ok so front direction
Now now if I multiple it by any number like LookVector*15 you get a vector3() value in which one value is 15 and other is 0, so now its not multiplying by any number so it would be
Vector3.new(0,0,0)

But whats the use of adding a vector with no value, i mean like it don’t have any change to the value as if you add 0 to 10 its 10 ofc no change at all so now whats the use of adding it, is that script line have another thing or its just there for nothing

If you multiply LookVector by 15 and that gives Vector3.new(15, 0, 0), then LookVector is Vector3.new(1, 0, 0).
If you do not multiply LookVector, it would in this case return Vector3.new(1, 0, 0), not Vector3.new(0, 0, 0).
If it helps, think of it as multiplying LookVector by 1, and then adding distancefromcam.

1 Like