Ad
Log in to vote
0

How do I stop my CFrame Lerping from flinging the plane?

Asked by
sasial 26
16 days ago

As you can see in the video, the plane is flinging when it moves:

Code: (ran on heartbeat)

        const delta = (tick() - this.delta) / this.speed;
        if (delta < 1) {
            print(delta);
            const position = new CFrame(this.path[0].CFrame.Position).Lerp(
                new CFrame(this.path[1].CFrame.Position),
                delta,
            );
            const orientation = this.plane.Move.CFrame.sub(this.plane.Move.Position).Lerp(
                this.path[1].CFrame.sub(this.path[1].CFrame.Position),
                delta,
            );
            const pivot = position.mul(orientation);
            this.plane.PivotTo(pivot);
        } else {
            if (this.path.size() > 2) {
                this.delta = tick();
                this.path.shift();
            } else {
                this.Destroy();
                print("Done!");
            }
        }

yes the code is in roblox-ts, but it'll be the essentially same in lua (with the except of the .sub macro compling to just a -)

Answer this question