2016-08-21 1 views

Répondre

0

Il y a deux façons principales d'animation; Le plus récent Animations et le plus ancien Joints. Le guide devrait être en mesure de vous aider à démarrer avec des animations. Il a même obtenu un video.

Si vous voulez utiliser un style ancien animation commun, quelque chose comme cela pourrait fonctionner:

local Block = script.Parent 

local function MakeFakeShoulder(Character, Side) 
    local Controller = { ["Stop"] = function() end } 

    local Torso = Character:findFirstChild("Torso") 
    local Arm = Character:findFirstChild(Side .. " Arm") 

    if not Torso or not Arm then return Controller end 

    local Shoulder = Torso:findFirstChild(Side .. " Shoulder") 
    if Shoulder then 
     local FakeShoulder = Instance.new("ManualWeld") 
     FakeShoulder.Name = "Fake " .. Side .. " Shoulder" 
     FakeShoulder.C0 = CFrame.new(1.5 * (Side == "Right" and 1 or -1),0.5,0) 
     FakeShoulder.C1 = CFrame.new(0,0.5,0) * CFrame.fromAxisAngle(Vector3.FromAxis(Enum.Axis.Z), math.rad(-180)) 
     FakeShoulder.Part0 = Torso 
     FakeShoulder.Part1 = Arm 
     FakeShoulder.Parent = Torso 

     Shoulder.Parent = nil 

     function Controller:Stop() 
      Shoulder.Parent = Torso 
      FakeShoulder:Destroy() 
     end 
    end 
    return Controller 
end 

local function MakeFakeShoulders(Character) 
    local Controller = { } 

    local Right = MakeFakeShoulder(Character, "Right") 
    local Left = MakeFakeShoulder(Character, "Left") 

    function Controller:Stop() 
     Right:Stop() 
     Left:Stop() 
    end 

    return Controller 
end 

local function GetHumanoid(Part) 
    if Part.Parent == nil then return nil end 
    return Part.Parent:findFirstChild("Humanoid") 
end 

local CurrentlyTouching = { } 
Block.Touched:connect(function(Part) 
    local Humanoid = GetHumanoid(Part) 
    if not Humanoid then return end 

    CurrentlyTouching[Humanoid] = CurrentlyTouching[Humanoid] or 0 
    CurrentlyTouching[Humanoid] = CurrentlyTouching[Humanoid] + 1 
    if CurrentlyTouching[Humanoid] > 1 then return end 

    local Controller = MakeFakeShoulders(Part.Parent) 

    while CurrentlyTouching[Humanoid] > 0 do 
     if GetHumanoid(Block.TouchEnded:wait()) == Humanoid then 
      CurrentlyTouching[Humanoid] = CurrentlyTouching[Humanoid] - 1 
     end 
    end 

    Controller:Stop() 
end) 

Notez que si la fin contact ne registre pas assez bon, faire une partie de délimitation CanCollide = false invisible qui est plus grand que la partie visuelle et mettre le script dans celui-là à la place,