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

Some dude told me to use CFrame Rotation Property but idk how in this situation help?

Asked by 3 years ago

So basically in my last post i posted this

local TS = game:GetService("TweenService")
local rarm = workspace.arm
local root = workspace.rot
rarm.Transparency = 0.7
rarm.Orientation = Vector3.new(22.52, -135.9, -69.64)
rarm.CFrame = root.CFrame + -root.CFrame.LookVector*2 + -root.CFrame.upVector*3 + -root.CFrame.RightVector*3
rarm:ClearAllChildren()
rarm.Anchored = true
function lerp(a, b, t)
    return a + (b - a) * t
end

function cubicBezier(t, p0, p1, p2, p3)
    local l1 = lerp(p0, p1, t)
    local l2 = lerp(p1, p2, t)
    local l3 = lerp(p2, p3, t)
    local a = lerp(l1, l2, t)
    local b = lerp(l2, l3, t)
    local cubic = lerp(a, b, t)
    return cubic
end

local f1 = root.Position + -root.CFrame.LookVector*2 + -root.CFrame.upVector*3 + -root.CFrame.RightVector*3
local f2 = root.Position + root.CFrame.LookVector*.8 + -root.CFrame.upVector*.15 + -root.CFrame.RightVector*5.5
local f3 = root.Position + root.CFrame.LookVector*5.25 + root.CFrame.upVector*.5 + -root.CFrame.RightVector*2.75
local f4 = root.Position + root.CFrame.LookVector*7.5 + root.CFrame.upVector*1.3 + root.CFrame.RightVector*1.5

spawn(function()
    for t = 0,1,.08 do
        local curve = cubicBezier(t,f1,f2,f3,f4)
        rarm.Position = curve
        game:GetService("RunService").Heartbeat:Wait()
    end;
end)

local TweenService = game:GetService("TweenService")
local rarm = workspace.arm
rarm.Orientation = Vector3.new(22.52, -135.9, -69.64)
local InfoA = TweenInfo.new(.25, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local GoalA = {
    Orientation = rarm.Orientation + Vector3.new(-0, -100, -50)
}
local TweenA = TweenService:Create(rarm, InfoA, GoalA)

TweenA:Play()

and someone said to use CFrame rotation property so i did this but still dont work :sob:

local TS = game:GetService("TweenService")
local rarm = workspace.arm
local root = workspace.rot
rarm.Transparency = 0.7
rarm.Orientation = Vector3.new(22.52, -135.9, -69.64)
rarm.CFrame = root.CFrame + -root.CFrame.LookVector*2 + -root.CFrame.upVector*3 + -root.CFrame.RightVector*3
rarm:ClearAllChildren()
rarm.Anchored = true
function lerp(a, b, t)
    return a + (b - a) * t
end

function cubicBezier(t, p0, p1, p2, p3)
    local l1 = lerp(p0, p1, t)
    local l2 = lerp(p1, p2, t)
    local l3 = lerp(p2, p3, t)
    local a = lerp(l1, l2, t)
    local b = lerp(l2, l3, t)
    local cubic = lerp(a, b, t)
    return cubic
end

local f1 = root.Position + -root.CFrame.LookVector*2 + -root.CFrame.upVector*3 + -root.CFrame.RightVector*3 * CFrame.Angles(math.rad(22.52),math.rad(-135.9),math.rad(-69.64))
local f2 = root.Position + root.CFrame.LookVector*.8 + -root.CFrame.upVector*.15 + -root.CFrame.RightVector*5.5 * CFrame.Angles(math.rad(22.52),math.rad(-135.9),math.rad(-69.64))
local f3 = root.Position + root.CFrame.LookVector*5.25 + root.CFrame.upVector*.5 + -root.CFrame.RightVector*2.75 * CFrame.Angles(math.rad(22.52),math.rad(-135.9),math.rad(-69.64))
local f4 = root.Position + root.CFrame.LookVector*7.5 + root.CFrame.upVector*1.3 + root.CFrame.RightVector*1.5 * CFrame.Angles(math.rad(22.52),math.rad(-135.9),math.rad(-69.64))

spawn(function()
    for t = 0,1,.08 do
        local curve = cubicBezier(t,f1,f2,f3,f4)
        rarm.Position = curve
        game:GetService("RunService").Heartbeat:Wait()
    end;
end)

please help

(what dude said: I see that you're incrementing the rotation of the object, this may cause issues when the rotation doesn't change linearly (which it doesn't in a cubic bezier curve).

One solution would be to interpolate CFrames instead of Vector3s when creating the Bézier curve, since CFrames have a rotation property. You can use CFrame:Lerp() to interpolate between CFrames.)

0
could you please tell us what you are trying to do with the script? sne_123456 439 — 3y

Answer this question