How to make a Custom character with Procedural leg animations in studio lite!

Поделиться
HTML-код
  • Опубликовано: 4 фев 2025

Комментарии • 39

  • @axolol-
    @axolol-  15 дней назад +2

    Procedural leg animations:
    local player = game:GetService("Players").LocalPlayer
    local character = player.Character
    local rootPart = character.HumanoidRootPart
    local head = character.UpperTorso --lower torso when actual character
    local camera = workspace.CurrentCamera
    local beam1, beam2 = workspace.beam1, workspace.beam2
    local pos1, pos2 = workspace.pos1, workspace.pos2
    local cf = CFrame.new
    local ang = CFrame.Angles
    local v3 = Vector3.new
    local ray = Ray.new
    local sin = math.sin
    local pi = math.pi
    local rad = math.rad
    local deg = math.deg
    local lastUpdate = 0
    local targLeft, targRight = v3(), v3()
    local oldLeft, oldRight = v3(), v3()
    local updateLeft = true
    local leftOff, rightOff = cf(-0.5, -0.5, 0), cf( 0.5, -0.5, 0)
    local lastspeed = 0
    local function getVel()
    local vel = rootPart.CFrame:vectorToObjectSpace(rootPart.Velocity)
    local speed = v3(vel.X, 0, vel.Z).magnitude
    return vel, speed
    end
    local function getDirection()
    local direction = camera.CFrame.lookVector
    local heading = math.atan2(-direction.X, -direction.Z)
    return heading
    end
    local function predictPosition(current, velocity, timeAhead)
    return current * cf(velocity * timeAhead)
    end
    local function getNextPosition(origin, zAngle, xAngle, length)
    local start = origin * ang(zAngle, 0, 0) * ang(0, 0, xAngle)
    local ray = ray(start.p, -start.UpVector * length)
    local hit, pos, nor = workspace:FindPartOnRayWithIgnoreList(ray, {character, beam1, beam2, pos1, pos2, workspace.Ignore})
    return pos
    end
    local function getLegToUpdate(predictedcf, vel)
    local nextLeft = getNextPosition(predictedcf * leftOff, rad(-vel.Z), rad(vel.X), 3)
    local nextRight = getNextPosition(predictedcf * rightOff, rad(-vel.Z), rad(vel.X), 3)
    local relLeft = (predictedcf:PointToObjectSpace((nextLeft + targRight)/2) * v3(1, 0, 1)).magnitude
    local relRight = (predictedcf:PointToObjectSpace((nextRight + targLeft)/2) * v3(1, 0, 1)).magnitude
    if relRight > relLeft then
    return true, nextLeft
    else
    return false, nextRight
    end
    end
    local function updateLegs(leftOrigin, rightOrigin, leftPos, rightPos)
    local d1 = (leftOrigin.p - leftPos).magnitude
    beam1.Size = v3(0.5, 0.5, d1)
    beam1.CFrame = cf(leftOrigin.p, leftPos) * cf(0, 0, -d1/2)
    local d2 = (rightOrigin.p - rightPos).magnitude
    beam2.Size = v3(0.5, 0.5, d2)
    beam2.CFrame = cf(rightOrigin.p, rightPos) * cf(0, 0, -d2/2)
    end
    game:GetService("RunService").RenderStepped:Connect(function(s)
    local vel, speed = getVel()
    local direction = getDirection()
    rootPart.CFrame = cf(rootPart.Position) * ang(0, direction, 0)
    local leftSet, rightSet
    if speed > 0 or math.abs(lastspeed-speed)/s > 0 then
    local delayOf = 0.2
    if lastUpdate + delayOf < tick() then
    lastUpdate = tick()
    local predictedcf = predictPosition(head.CFrame, vel, delayOf)--*1.5)
    local leftLeg, setPos = getLegToUpdate(predictedcf, vel)
    updateLeft = leftLeg
    if leftLeg then
    oldLeft = targLeft
    targLeft = setPos
    else
    oldRight = targRight
    targRight = setPos
    end
    end
    local alpha = math.min((tick()-lastUpdate)/(delayOf/2), 1)
    if updateLeft then
    leftSet = oldLeft:lerp(targLeft, alpha) + v3(0, 0.75*sin(pi*alpha), 0)
    rightSet = targRight
    else
    rightSet = oldRight:lerp(targRight, alpha) + v3(0, 0.75*sin(pi*alpha), 0)
    leftSet = targLeft
    end
    else
    targLeft = getNextPosition(head.CFrame * leftOff, rad(10), rad(-5), 3)
    targRight = getNextPosition(head.CFrame * rightOff, rad(-10), rad(5), 3)
    oldLeft, oldRight = targLeft, targRight
    leftSet, rightSet = targLeft, targRight
    end
    pos1.Position = leftSet
    pos2.Position = rightSet
    updateLegs(head.CFrame * leftOff, head.CFrame * rightOff, leftSet, rightSet)
    lastspeed = speed
    end)

    • @JimxyneilGalvajar
      @JimxyneilGalvajar 15 дней назад +1

      You could just put it in the description it's more easier to copy

    • @axolol-
      @axolol-  15 дней назад

      ​@@JimxyneilGalvajarOk so about that. I can't, because for some weird reason RUclips doesn't allow angled brackets on descriptions.

    • @MEGAANJARSARI-c1p
      @MEGAANJARSARI-c1p 15 дней назад +1

      /copy

    • @Best_Junior5
      @Best_Junior5 15 дней назад +1

      /copy

    • @Best_Junior5
      @Best_Junior5 15 дней назад +1

      Why don't you just upload another vidoe with titled "Procedular Legs Anim!" And put script in Desc

  • @Kuro_TheDev
    @Kuro_TheDev 15 дней назад +4

    This guy will be the next star in studio lite community 🎉

    • @axolol-
      @axolol-  15 дней назад

      Thank you so much!

    • @Kemehstar
      @Kemehstar 15 дней назад +1

      ​@@axolol-hi

    • @axolol-
      @axolol-  15 дней назад

      Hiya!

  • @silanroslan
    @silanroslan 3 дня назад +1

    Wait, did you remove the ball? Cus i cant do anything cus of the ball. I wanna know if you delete it
    New sub :D

    • @axolol-
      @axolol-  3 дня назад

      Heya! I'm guessing you can't move because of the ball? There's a pretty simple fix for that and all you need to do is Turn off CanCollide on the ball.
      Hope this helps!

    • @silanroslan
      @silanroslan 2 дня назад

      Oh thanks!

  • @SiLanRoslan145
    @SiLanRoslan145 2 дня назад +1

    I must put body name or part on the script for ball? Also, did you remove the ball after the script done because it randomly appear at replicated strorage. Sorry for so much complain :( btw new sub

    • @axolol-
      @axolol-  2 дня назад

      Yes, you do need to put the name of the ball/custom char Inside of the script. The ball also needs to be placed inside of replicated storage. And no I did not remove the ball I just turned off the CanCollide property on it.

  • @WoofGodYT
    @WoofGodYT 15 дней назад +1

    thank you sir

  • @BloxyColaXD-R
    @BloxyColaXD-R 2 дня назад +2

    I can't copy the comment :(

    • @axolol-
      @axolol-  День назад

      You can go into chrome and copy my comment that way

  • @_deman
    @_deman 14 дней назад +1

    We be making eg with this one

    • @axolol-
      @axolol-  14 дней назад

      Eg 🗣️🔥🔥🗣️🔥🔥🔥

  • @a_random_white_guy
    @a_random_white_guy 15 дней назад +1

    Invisible Player script incase you need:
    -- Function to make a player's character invisible
    local function makePlayerInvisible(player)
    local character = player.Character or player.CharacterAdded:Wait()
    for _, part in pairs(character:GetDescendants()) do
    if part:IsA("BasePart") and part.Name ~= "HumanoidRootPart" then
    part.Transparency = 1 -- Makes the part invisible
    part.CanCollide = false -- Prevents collisions
    elseif part:IsA("Decal") then
    part.Transparency = 1 -- Hides face decals
    end
    end
    end
    -- Trigger invisibility when a player joins
    game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
    wait(1) -- Allow the character to load fully
    makePlayerInvisible(player)
    end)
    end)

    • @axolol-
      @axolol-  15 дней назад

      Hi! Sorry for the delay for some reason RUclips is marking your comment as held. (Which basically hides ur comment)

    • @a_random_white_guy
      @a_random_white_guy 15 дней назад +1

      Is ok​@@axolol-

    • @a_random_white_guy
      @a_random_white_guy 15 дней назад +1

      ​@@axolol-i have a slight problem with the script Because when i tried it when using the script, the script thinks the Head of the custom character is a part of the head that is why i Will make the entire body gone except for the head

    • @axolol-
      @axolol-  14 дней назад

      ​​@@a_random_white_guyHmm, maybe try to detect for MeshParts only and not BaseParts.
      For example:
      if part:IsA("MeshPart") then
      --invisibility here

    • @a_random_white_guy
      @a_random_white_guy 14 дней назад

      ​@@axolol-Oka

  • @The_oneandonlykurtboy
    @The_oneandonlykurtboy 15 дней назад +1

    Now to make the legs disappears?

    • @axolol-
      @axolol-  15 дней назад +1

      You can use @a_random_white_guy script