Quick actions

cmd+k|ctrl+k

Navigation

Languages

oluwamark v2

Snippet info

Language

Lua

Visibility

public

Author

dinoturto

Created

2024-03-14T08:48:37.287443Z

Updated

2024-03-22T20:41:09.17679Z

local chr = owner.Character
local root = chr.HumanoidRootPart
local hum = chr.Humanoid

local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.IgnoreWater = true
raycastParams.RespectCanCollide = true
raycastParams.FilterDescendantsInstances = {chr}

function joint(p0, p1, c0, c1, name)
    local w = Instance.new("Weld")
    w.Part0 = p0
    w.Part1 = p1
    w.C0 = c0
    w.C1 = c1
    w.Name = name
    w.Parent = p0
    return w
end

local nk = joint(chr.Torso, chr.Head, CFrame.new(0, 1, 0), CFrame.new(0, -1/2, 0), "Neck")
local rj = joint(root, chr.Torso, CFrame.new(0, 0, 0), CFrame.new(0, 0, 0), "RootJoint")
local rs = joint(chr.Torso, chr:FindFirstChild("Right Arm"), CFrame.new(1.5, 0.5, 0), CFrame.new(0, 0.5, 0), "Right Shoulder")
local ls = joint(chr.Torso, chr:FindFirstChild("Left Arm"), CFrame.new(-1.5, 0.5, 0), CFrame.new(0, 0.5, 0), "Left Shoulder")
local rh = joint(chr.Torso, chr:FindFirstChild("Right Leg"), CFrame.new(0.5, -1, 0), CFrame.new(0, 1, 0), "Right Hip")
local lh = joint(chr.Torso, chr:FindFirstChild("Left Leg"), CFrame.new(-0.5, -1, 0), CFrame.new(0, 1, 0), "Left Hip")

local rsc0, lsc0, rhc0, lhc0, rjc0, nkc0 = rs.C0, ls.C0, rh.C0, lh.C0, rj.C0, nk.C0

local t = os.clock()
local exactVel = 0
local vel = 0
local animMove = false
local action = "Fly"

local animTable = {
    ["Fly"] = function(t, vel)
        return {
            ["rj"] = rjc0 * CFrame.new(-math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 4, math.sin(t / 5) / 20, 0) *
                CFrame.Angles(-math.cos(t / 5) / 20, math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 4, 0),
            ["nk"] = nkc0 * CFrame.Angles(-math.rad(15) - math.cos(t / 5) / 20 + math.sin(t / 35 + math.sin(t / 35)) / 2.5, 0, 0),
            ["rs"] = rsc0 * CFrame.new(-math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 3, -0.2 + math.cos(t / 5) / 8 + math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 8, -0.25 - math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 2) *
                CFrame.Angles(math.rad(20) + math.sin(t / 5) / 4 + math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 2, math.rad(20) + math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 2, -math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 2 - math.cos(t / 5) / 8 - math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 2),
            ["ls"] = lsc0 * CFrame.new(-math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 3, -0.2 + math.cos(t / 5) / 8 - math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 8, -0.25 + math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 2) *
                CFrame.Angles(math.rad(20) + math.sin(t / 5) / 4 - math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 2, -math.rad(20) + math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 2, -math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 2 + math.cos(t / 5) / 8 - math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 2),
            ["rh"] = rhc0 * CFrame.new(math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 4, -math.sin(t / 5) / 20, math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 8 - math.cos(t / 5) / 20) *
                CFrame.new(0.075 - math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 8, 0, math.cos(t / 5) / 5) *
                CFrame.Angles(math.cos(t / 5) / 20, -math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 4, 0) *
                CFrame.Angles(-math.rad(8) + math.cos(t / 5) / 10, -math.rad(15) - math.sin(t / 5) / 3, math.rad(5) + math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 8),
            ["lh"] = lhc0 * CFrame.new(math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 4, -math.sin(t / 5) / 20, -math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 8 - math.cos(t / 5) / 20) *
                CFrame.new(-0.075 - math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 8, 0, math.cos(t / 5) / 5) *
                CFrame.Angles(math.cos(t / 5) / 20, -math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 4, 0) *
                CFrame.Angles(-math.rad(8) + math.cos(t / 5) / 10, math.rad(15) + math.sin(t / 5) / 3, -math.rad(5) + math.sinh(math.sin(math.sin(t / 22.5))) ^ 3 / 8)
        }
    end;
}

local joints = {["rj"] = rj, ["nk"] = nk, ["rs"] = rs, ["ls"] = ls, ["rh"] = rh, ["lh"] = lh}

game:GetService("RunService").PostSimulation:Connect(function(dt)
    t = os.clock() * 60
    
    exactVel = CFrame.new(root.CFrame:VectorToObjectSpace(root.Velocity))
    vel = Vector3.new(math.clamp(exactVel.x, -32, 32), math.clamp(exactVel.y, -32, 32), math.clamp(exactVel.z, -32, 32))
    
    if animMove then
        if hum:GetState() ~= Enum.HumanoidStateType.Climbing then
            if not hum.Sit then
                if hum.FloorMaterial == Enum.Material.Air then
                    action = "Fall"
                else
                    action = hum.MoveDirection.Magnitude > 0 and "Walk" or "Idle"
                end
            else
                action = "Sit"
            end
        else
            if math.abs(vel.Y) > 0 then
                action = "Climb"
            end
        end
    end
    
    for i, v in next, joints do
        v.C0 = v.C0:Lerp(animTable[action](t, vel)[i], 0.3 * dt * 60)
    end
end)
INFO