Alright so, I’ve got the following problem:
I want to get a quarter between two points, like this
Try using Vector3 | Roblox Creator Documentation .Magnitude and just divide it by 4, or 2 or whatever increment you want.
Probably there is better way but this is my lazy way; CFrame.new(pointB - pointA).LookVector * magnitude(quater or half) + pointA
Edit:Thanks to Mishajones, I felt bad about it after noticing vecter.Lerp. I’ll go and post this in the “Worst lines of code” thread
Hello!
You can use Vector3:Lerp(goal, fraction)
for this, where the goal is a Vector3 and the fraction is a number. For example, to go from vector A to B and stop at a quarter (ie 0.25) of the total distance (or 1), you would do A:Lerp(B, 0.25)
.
There are more functions on Vector3 in its documentation page.
7 Likes
local direction = (pointB - pointA).Unit
local distance = (pointB - pointA).Magnitude
local quarter = pointA + (direction * distance * 0.25)
1 Like