So I am making an entity system, and dont suggest me to use for i loops to get alpha as it reduces performance for the 100s of entities for me to render.
local Time = 0;
local startPosition = script.Parent.Position;
local TimeToBe = workspace:GetServerTimeNow() + 5
while (Time < TimeToBe) do
local alpha = (startPosition + (startPosition - script.Parent.Parent.Part2.Position)).Magnitude * Time / TimeToBe
local lerp =
script.Parent.Position:Lerp(script.Parent.Parent.Part2.Position, alpha)
script.Parent.Position = lerp
print(script.Parent.Position)
Time = workspace:GetServerTimeNow();
task.wait()
end
script.Parent.Position = script.Parent.Parent.Part2.Position
I dont understand whats wrong with it but it keeps going to like the millions in the x,y,z positions.
this is an example i tried to do for how i will calculate alpha in the future
Yeah, that is more or less what I suspected.
I think It may be to do with where you have put .Magnitude. Currently, it is ((a + (b-a)) * t instead of a + (b-a)*t
If you print out individual parts of it, what does it output? (e.g. print out the startPosition magnitude, then the magnitude when there was a subtraction, then the time / timetobe thing)