What’s diffrence?
Part.CFrame = Part.CFrame + Part.CFrame.LookVector * 5
Part.CFrame = Part.CFrame + Part.CFrame.LookVector * Vector3.new(0, 0, 5)
What’s diffrence?
Part.CFrame = Part.CFrame + Part.CFrame.LookVector * 5
Part.CFrame = Part.CFrame + Part.CFrame.LookVector * Vector3.new(0, 0, 5)
The former multiplies all components by 5, the latter multiplies the X
and Y
components by 0, and the Z
by 5.
hmm, then how can I move Part 5 studs using LookVector? (move 5 studs by part facing)
That would be how you do it, yes. Adding a CFrame with a Vector3 will add to the CFrame’s Position
, so it will be moved forward by 5 as you want it
so I should use this one
Part.CFrame = Part.CFrame + Part.CFrame.LookVector * Vector3.new(0, 0, 5)
If you want? The X
and Y
components of the LookVector
will be zero anyway, but I find multiplying explicitly by a scalar is more readable.
Nah you use the first one. Or:
Part.CFrame = Part.CFrame * CFrame.new(0, 0, -5)
wow I did not know that is also possible. I’ve always been using
Part.CFrame = Part.CFrame + Part.CFrame.LookVector*n