#Bezier Curve Smoothness

27 messages · Page 1 of 1 (latest)

severe saddle
#

ab

#
local function TweenArm(arm)
    spawn(function()
        local armStartCf = arm.CFrame
        local timeElapsed = 0


        local rnd = Random.new()
        local rndCF = CFrame.new(rnd:NextInteger(-7,7),rnd:NextNumber(-6.5,6.5),rnd:NextNumber(-3,7.5))

        local speed = script.Parent:GetAttribute("speed")
        local duration = (armStartCf.p - pivotCFrame.Position).Magnitude / speed
        local tweenDelay = 0.1

        timeElapsed = 0
        while timeElapsed < duration do
            local progress = timeElapsed / duration
            local pointAtTimeElapsed = Bezier_Module:QuadraticBezier(progress,armStartCf.p,(armStartCf * rndCF).p, pivotCFrame.p)
            local lookAt = Bezier_Module:QuadraticBezier(progress+0.01,armStartCf.p,(armStartCf * rndCF).p, pivotCFrame.p)


            if timeElapsed == 0 then
                arm.CFrame = CFrame.new(pointAtTimeElapsed,Bezier_Module:QuadraticBezier(progress+.01,armStartCf.p,(armStartCf * rndCF).p, pivotCFrame.p)) 
            elseif timeElapsed == speed then
                local tween = TweenService:Create(arm,TweenInfo.new(.4),{Transparency = 1}):Play()
            end

            timeElapsed += speed

            local tween = TweenService:Create(arm,TweenInfo.new(tweenDelay),{CFrame = CFrame.new(pointAtTimeElapsed,lookAt)})
            tween:Play()
            game:GetService("TweenService"):Create(arm,TweenInfo.new(duration,Enum.EasingStyle.Quad),{Transparency = 1}):Play()

            wait(tweenDelay)
        end

        arm:Destroy()
    end)
end
#
while task.wait() do
    local arm = game.ReplicatedStorage.Arm:Clone()
    
    
    local Hitbox = V4.new(arm)
    Hitbox:SetPoints(arm, {Vector3.new(0, 0, 0), Vector3.new(-0.5, 0, 0), Vector3.new(0.5, 0, 0), Vector3.new(0, 1, 0), Vector3.new(-0.5, 1, 0), Vector3.new(0.5, 1, 0), Vector3.new(0, -1, 0), Vector3.new(-0.5, -1, 0), Vector3.new(0.5, -1, 0)})
    Hitbox:HitStart()

    arm.Position = script.Parent.Position
    arm.Parent = script.Parent
    pivotCFrame = CFrame.new(script.Parent.Attachment.WorldPosition)
    TweenArm(arm)
    
    
    
    
    Hitbox.OnHit:Connect(function(hit, humanoid)
        if humanoid and humanoid ~= Human then
            local Damage = math.random(.5,1)
            humanoid:TakeDamage(Damage)
        end
    end)
end
#

unsmooth very unhappy

boreal ibex
severe saddle
#

bet

boreal ibex
#

next, show a gif

severe saddle
#

let me

boreal ibex
#

of it playing

severe saddle
#

wait

#

watch untill the end

#

you can see the difference

boreal ibex
#

dayum

boreal ibex
#

whats different from the first and second time

severe saddle
#

The first part seems smoother to me

#

than the second one

boreal ibex
#

take out tween.Completed:Wait() and replace it with task.wait(tweenDelay*0.9)

#

or 0.95

severe saddle
#

alr

severe saddle
#

i might be going insane

boreal ibex
severe saddle
#

I think im tweaking

severe saddle
#

i'm slowly going insane

#

or the script is messed up