Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

CFrame lerping is re-positioning and rotating without known reason to? [problem resolved]

Asked by 7 years ago
Edited 7 years ago

**EDIT: I fixed my problem by defining the CFrames using quaternions, instead of two Vector3s.


So, I am attempting to make a tsunami. It changes position using lerp. Simple enough, yes?

I got both of the CFrames by positioning the 'tsunami' part, then using the command bar to return their CFrames.

The lookVector stayed the same through every position change - yet during the lerp, the part did a full rotation on the X axis, and a bit on the others.

--// v3 and cf have been defined as Vector3.new and CFrame.new
--// All other variables have been defined

local startC,endC = cf(v3(-1322, -40, 7),v3(1, -0, -0)),cf(v3(800, -40.5, 7),v3(1, -0, -0))
local startPos,endPos = startC.p,endC.p
local magnitude = (startPos-endPos).Magnitude

local step = 1/magnitude
local hold = 1/tsunamiTime --// Also, if anyone could boost my memory on how to calculate this, that'd be great!

for i = 0,1,step do
    part.CFrame = startC:lerp(endC,i)
    print(i)
    wait(hold)
end

Thank you!

~TDP

0
Can you please close this question so people don't spam and answer. Thanks TheUniPiggy 77 — 7y
0
I cannot close my own question. I will not delete it because this problem may occur for someone else. TheDeadlyPanther 2460 — 7y

Answer this question