2016-08-21 47 views

回答

0

有動畫的兩種途徑;較新的Animations和較舊的Joints

guide應該能夠幫助您開始動畫。它甚至有一個video

如果你想使用舊式聯合動漫,這樣的事情可能工作:

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) 

注意,如果最終觸摸不登記不夠好,做一個隱形CanCollide = false包圍的部分是比大視覺部分,並把劇本放在那一個,