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

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.พ. 2025
  • Tags and script
    #robloxstudio #roblox #robloxstudioscripting #studiolite #robloxstudiotutorial #lighting #robloxgraphics #ligma #hdr #shader
    Script 01: custom character
    game.Players.PlayerAdded:Connect(function(player)
    local character = player.Character or player.CharacterAdded:Wait()
    local part = game.ReplicatedStorage.ChangeThisToYourPartName:Clone()
    part.Parent = character
    local Weld = Instance.new("Weld", part)
    Weld.Name = "Weld"
    Weld.Part0 = part
    Weld.Part1 = character.Head
    end)
    ______________________________________________
    Script 02: procedural leg anims:
    In the comments since TH-cam doesn't allow angled brackets on descriptions :(

ความคิดเห็น • 39

  • @axolol-
    @axolol-  18 วันที่ผ่านมา +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 18 วันที่ผ่านมา +1

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

    • @axolol-
      @axolol-  18 วันที่ผ่านมา

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

    • @MEGAANJARSARI-c1p
      @MEGAANJARSARI-c1p 18 วันที่ผ่านมา +1

      /copy

    • @PoloX1-q1e
      @PoloX1-q1e 18 วันที่ผ่านมา +1

      /copy

    • @PoloX1-q1e
      @PoloX1-q1e 18 วันที่ผ่านมา +1

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

  • @Kuro_TheDev
    @Kuro_TheDev 18 วันที่ผ่านมา +4

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

    • @axolol-
      @axolol-  18 วันที่ผ่านมา

      Thank you so much!

    • @Kemehstar
      @Kemehstar 18 วันที่ผ่านมา +1

      ​@@axolol-hi

    • @axolol-
      @axolol-  18 วันที่ผ่านมา

      Hiya!

  • @WoofGodYT
    @WoofGodYT 18 วันที่ผ่านมา +1

    thank you sir

  • @silanroslan
    @silanroslan 6 วันที่ผ่านมา +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-  6 วันที่ผ่านมา

      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 5 วันที่ผ่านมา

      Oh thanks!

  • @SiLanRoslan145
    @SiLanRoslan145 5 วันที่ผ่านมา +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-  5 วันที่ผ่านมา

      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.

  • @BloxyColaXD-R
    @BloxyColaXD-R 5 วันที่ผ่านมา +2

    I can't copy the comment :(

    • @axolol-
      @axolol-  4 วันที่ผ่านมา

      You can go into chrome and copy my comment that way

  • @a_random_white_guy
    @a_random_white_guy 18 วันที่ผ่านมา +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-  18 วันที่ผ่านมา

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

    • @a_random_white_guy
      @a_random_white_guy 18 วันที่ผ่านมา +1

      Is ok​@@axolol-

    • @a_random_white_guy
      @a_random_white_guy 17 วันที่ผ่านมา +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-  17 วันที่ผ่านมา

      ​​@@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 17 วันที่ผ่านมา

      ​@@axolol-Oka

  • @_deman
    @_deman 17 วันที่ผ่านมา +1

    We be making eg with this one

    • @axolol-
      @axolol-  16 วันที่ผ่านมา

      Eg 🗣️🔥🔥🗣️🔥🔥🔥

  • @The_oneandonlykurtboy
    @The_oneandonlykurtboy 18 วันที่ผ่านมา +1

    Now to make the legs disappears?

    • @axolol-
      @axolol-  18 วันที่ผ่านมา +1

      You can use @a_random_white_guy script