배우기
엔진 클래스
AnimationTrack
만들 수 없음

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.



API 참조
속성
Animation
읽기 전용
복제되지 않음
병렬 읽기
기능: Animation
AnimationTrack.Animation:Animation
코드 샘플
새 애니메이션 수신
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
animator.AnimationPlayed:Connect(function(animationTrack)
local animationName = animationTrack.Animation.Name
print("애니메이션 재생 중: " .. animationName)
end)

IsPlaying
읽기 전용
복제되지 않음
병렬 읽기
기능: Animation
시뮬레이션 액세스
AnimationTrack.IsPlaying:boolean
코드 샘플
AnimationTrack 재생 여부
local function playOrAdjust(animationTrack, fadeTime, weight, speed)
if not animationTrack.IsPlaying then
animationTrack:Play(fadeTime, weight, speed)
else
animationTrack:AdjustSpeed(speed)
animationTrack:AdjustWeight(weight, fadeTime)
end
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
playOrAdjust(animationTrack, 1, 0.6, 1)

Length
읽기 전용
복제되지 않음
병렬 읽기
기능: Animation
AnimationTrack.Length:number
코드 샘플
특정 기간 동안 애니메이션 재생
local function playAnimationForDuration(animationTrack, duration)
local speed = animationTrack.Length / duration
animationTrack:Play()
animationTrack:AdjustSpeed(speed)
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765000"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
playAnimationForDuration(animationTrack, 3)

Looped
병렬 읽기
기능: Animation
시뮬레이션 액세스
AnimationTrack.Looped:boolean
코드 샘플
애니메이션 루핑
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
while not localPlayer.Character do
task.wait()
end
local character = localPlayer.Character
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507770453"
local animationTrack = animator:LoadAnimation(animation)
animationTrack.Looped = false
task.wait(3)
animationTrack:Play()
task.wait(4)
animationTrack.Looped = true
animationTrack:Play()
여러 번 반복하는 AnimationTrack 재생
local function playForNumberLoops(animationTrack, number)
animationTrack.Looped = true
animationTrack:Play()
local numberOfLoops = 0
local connection = nil
connection = animationTrack.DidLoop:Connect(function()
numberOfLoops = numberOfLoops + 1
print("loop: ", numberOfLoops)
if numberOfLoops >= number then
animationTrack:Stop()
connection:Disconnect() -- 더 이상 필요하지 않을 때는 연결을 해제하는 것이 중요합니다
end
end)
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
playForNumberLoops(animationTrack, 5)

Priority
병렬 읽기
기능: Animation
시뮬레이션 액세스
AnimationTrack.Priority:Enum.AnimationPriority

Speed
읽기 전용
복제되지 않음
병렬 읽기
기능: Animation
시뮬레이션 액세스
AnimationTrack.Speed:number
코드 샘플
애니메이션 속도
local ContentProvider = game:GetService("ContentProvider")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
while not localPlayer.Character do
task.wait()
end
local character = localPlayer.Character
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507770453"
ContentProvider:PreloadAsync({ animation })
local animationTrack = animator:LoadAnimation(animation)
local normalSpeedTime = animationTrack.Length / animationTrack.Speed
animationTrack:AdjustSpeed(3)
local fastSpeedTime = animationTrack.Length / animationTrack.Speed
print("보통 속도에서 애니메이션은", normalSpeedTime, "초 동안 재생됩니다")
print("3배 속도에서 애니메이션은", fastSpeedTime, "초 동안 재생됩니다")
특정 기간 동안 애니메이션 재생
local function playAnimationForDuration(animationTrack, duration)
local speed = animationTrack.Length / duration
animationTrack:Play()
animationTrack:AdjustSpeed(speed)
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765000"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
playAnimationForDuration(animationTrack, 3)

TimePosition
복제되지 않음
병렬 읽기
기능: Animation
시뮬레이션 액세스
AnimationTrack.TimePosition:number
코드 샘플
위치에서 애니메이션 정지
function freezeAnimationAtTime(animationTrack, timePosition)
if not animationTrack.IsPlaying then
-- 애니메이션이 재생되지 않는 경우 재생합니다
animationTrack:Play()
end
-- 애니메이션을 정지시키기 위해 속도를 0으로 설정합니다
animationTrack:AdjustSpeed(0)
-- 원하는 TimePosition으로 순간이동합니다
animationTrack.TimePosition = timePosition
end
function freezeAnimationAtPercent(animationTrack, percentagePosition)
if not animationTrack.IsPlaying then
-- 애니메이션이 재생되지 않는 경우 재생합니다
animationTrack:Play()
end
-- 애니메이션을 정지시키기 위해 속도를 0으로 설정합니다
animationTrack:AdjustSpeed(0)
-- 원하는 TimePosition으로 순간이동합니다
animationTrack.TimePosition = (percentagePosition / 100) * animationTrack.Length
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
freezeAnimationAtTime(animationTrack, 0.5)
freezeAnimationAtPercent(animationTrack, 50)

WeightCurrent
읽기 전용
복제되지 않음
병렬 읽기
기능: Animation
시뮬레이션 액세스
AnimationTrack.WeightCurrent:number
코드 샘플
WeightCurrent 및 WeightTarget
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
while not localPlayer.Character do
task.wait()
end
local character = localPlayer.Character
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animation1 = Instance.new("Animation")
animation1.AnimationId = "rbxassetid://507770453"
local animation2 = Instance.new("Animation")
animation2.AnimationId = "rbxassetid://507771019"
task.wait(3) -- 캐릭터가 자리에 떨어지도록 허용하기 위한 임의의 대기 시간
local animationTrack1 = animator:LoadAnimation(animation1)
local animationTrack2 = animator:LoadAnimation(animation2)
animationTrack1.Priority = Enum.AnimationPriority.Movement
animationTrack2.Priority = Enum.AnimationPriority.Action
animationTrack1:Play(0.1, 5, 1)
animationTrack2:Play(10, 3, 1)
local done = false
while not done and task.wait(0.1) do
if math.abs(animationTrack2.WeightCurrent - animationTrack2.WeightTarget) < 0.001 then
print("도착했습니다")
done = true
end
end

WeightTarget
읽기 전용
복제되지 않음
병렬 읽기
기능: Animation
시뮬레이션 액세스
AnimationTrack.WeightTarget:number
코드 샘플
WeightCurrent 및 WeightTarget
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
while not localPlayer.Character do
task.wait()
end
local character = localPlayer.Character
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animation1 = Instance.new("Animation")
animation1.AnimationId = "rbxassetid://507770453"
local animation2 = Instance.new("Animation")
animation2.AnimationId = "rbxassetid://507771019"
task.wait(3) -- 캐릭터가 자리에 떨어지도록 허용하기 위한 임의의 대기 시간
local animationTrack1 = animator:LoadAnimation(animation1)
local animationTrack2 = animator:LoadAnimation(animation2)
animationTrack1.Priority = Enum.AnimationPriority.Movement
animationTrack2.Priority = Enum.AnimationPriority.Action
animationTrack1:Play(0.1, 5, 1)
animationTrack2:Play(10, 3, 1)
local done = false
while not done and task.wait(0.1) do
if math.abs(animationTrack2.WeightCurrent - animationTrack2.WeightTarget) < 0.001 then
print("도착했습니다")
done = true
end
end

메서드
AdjustSpeed
기능: Animation
시뮬레이션 액세스
AnimationTrack:AdjustSpeed(speed:number):()
매개 변수
speed:number
기본값: 1
반환
()
코드 샘플
특정 기간 동안 애니메이션 재생
local function playAnimationForDuration(animationTrack, duration)
local speed = animationTrack.Length / duration
animationTrack:Play()
animationTrack:AdjustSpeed(speed)
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765000"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
playAnimationForDuration(animationTrack, 3)
애니메이션 속도
local ContentProvider = game:GetService("ContentProvider")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
while not localPlayer.Character do
task.wait()
end
local character = localPlayer.Character
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507770453"
ContentProvider:PreloadAsync({ animation })
local animationTrack = animator:LoadAnimation(animation)
local normalSpeedTime = animationTrack.Length / animationTrack.Speed
animationTrack:AdjustSpeed(3)
local fastSpeedTime = animationTrack.Length / animationTrack.Speed
print("보통 속도에서 애니메이션은", normalSpeedTime, "초 동안 재생됩니다")
print("3배 속도에서 애니메이션은", fastSpeedTime, "초 동안 재생됩니다")

AdjustWeight
기능: Animation
시뮬레이션 액세스
AnimationTrack:AdjustWeight(
weight:number, fadeTime:number
):()
매개 변수
weight:number
기본값: 1
fadeTime:number
기본값: 0.100000001
반환
()
코드 샘플
애니메이션 트랙 가중치 변경
local function changeWeight(animationTrack, weight, fadeTime)
animationTrack:AdjustWeight(weight, fadeTime)
local startTime = tick()
while math.abs(animationTrack.WeightCurrent - weight) > 0.001 do
task.wait()
end
print("가중치를 변경하는 데 걸린 시간 " .. tostring(tick() - startTime))
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
changeWeight(animationTrack, 0.6, 1)

GetMarkerReachedSignal
기능: Animation
AnimationTrack:GetMarkerReachedSignal(name:string):RBXScriptSignal
매개 변수
name:string
코드 샘플
키프레임 마커 듣기
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.Character:Wait()
local humanoid = character:WaitForChild("Humanoid")
-- 새로운 "Animation" 인스턴스 생성
local kickAnimation = Instance.new("Animation")
-- 해당 애니메이션 자산 ID에 "AnimationId" 설정
kickAnimation.AnimationId = "rbxassetid://2515090838"
-- 애니메이션을 휴머노이드에 로드
local kickAnimationTrack = humanoid:LoadAnimation(kickAnimation)
-- 애니메이션 트랙 재생
kickAnimationTrack:Play()
-- 애니메이션을 위한 이름이 지정된 이벤트가 정의되었다면, "GetMarkerReachedSignal()"에 연결
kickAnimationTrack:GetMarkerReachedSignal("KickEnd"):Connect(function(paramString)
print(paramString)
end)

GetParameter
기능: Animation
시뮬레이션 액세스
AnimationTrack:GetParameter(key:string):Variant
매개 변수
key:string
반환
Variant

GetParameterDefaults
기능: Animation
AnimationTrack:GetParameterDefaults():Dictionary

GetTargetInstance
기능: Animation
AnimationTrack:GetTargetInstance(name:string):Instance?
매개 변수
name:string
반환

GetTargetNames
기능: Animation
AnimationTrack:GetTargetNames():{any}
반환

GetTimeOfKeyframe
기능: Animation
AnimationTrack:GetTimeOfKeyframe(keyframeName:string):number
매개 변수
keyframeName:string
반환
코드 샘플
키프레임으로 점프하기
local function jumpToKeyframe(animationTrack, keyframeName)
local timePosition = animationTrack:GetTimeOfKeyframe(keyframeName)
if not animationTrack.IsPlaying then
animationTrack:Play()
end
animationTrack.TimePosition = timePosition
end
local ANIMATION_ID = 0
local KEYFRAME_NAME = "테스트"
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://" .. ANIMATION_ID
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
jumpToKeyframe(animationTrack, KEYFRAME_NAME)

Play
기능: Animation
시뮬레이션 액세스
AnimationTrack:Play(
fadeTime:number, weight:number, speed:number
):()
매개 변수
fadeTime:number
기본값: 0.100000001
weight:number
기본값: 1
speed:number
기본값: 1
반환
()
코드 샘플
특정 기간 동안 애니메이션 재생
local function playAnimationForDuration(animationTrack, duration)
local speed = animationTrack.Length / duration
animationTrack:Play()
animationTrack:AdjustSpeed(speed)
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765000"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
playAnimationForDuration(animationTrack, 3)
위치에서 애니메이션 정지
function freezeAnimationAtTime(animationTrack, timePosition)
if not animationTrack.IsPlaying then
-- 애니메이션이 재생되지 않는 경우 재생합니다
animationTrack:Play()
end
-- 애니메이션을 정지시키기 위해 속도를 0으로 설정합니다
animationTrack:AdjustSpeed(0)
-- 원하는 TimePosition으로 순간이동합니다
animationTrack.TimePosition = timePosition
end
function freezeAnimationAtPercent(animationTrack, percentagePosition)
if not animationTrack.IsPlaying then
-- 애니메이션이 재생되지 않는 경우 재생합니다
animationTrack:Play()
end
-- 애니메이션을 정지시키기 위해 속도를 0으로 설정합니다
animationTrack:AdjustSpeed(0)
-- 원하는 TimePosition으로 순간이동합니다
animationTrack.TimePosition = (percentagePosition / 100) * animationTrack.Length
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
freezeAnimationAtTime(animationTrack, 0.5)
freezeAnimationAtPercent(animationTrack, 50)

SetParameter
기능: Animation
시뮬레이션 액세스
AnimationTrack:SetParameter(
key:string, value:Variant
):()
매개 변수
key:string
value:Variant
반환
()

SetTargetInstance
기능: Animation
AnimationTrack:SetTargetInstance(
name:string, target:Instance?
):()
매개 변수
name:string
target:Instance?
반환
()

Stop
기능: Animation
시뮬레이션 액세스
AnimationTrack:Stop(fadeTime:number):()
매개 변수
fadeTime:number
기본값: 0.100000001
반환
()
코드 샘플
애니메이션 트랙 중지
local function fadeOut(animationTrack, fadeTime)
animationTrack:Stop(fadeTime)
local startTime = tick()
while animationTrack.WeightCurrent > 0 do
task.wait()
end
local timeTaken = tick() - startTime
print("가중치가 재설정되는 데 걸린 시간: " .. tostring(timeTaken))
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
animationTrack:Play()
fadeOut(animationTrack, 1)

이벤트
DidLoop
기능: Animation
AnimationTrack.DidLoop():RBXScriptSignal
코드 샘플
여러 번 반복하는 AnimationTrack 재생
local function playForNumberLoops(animationTrack, number)
animationTrack.Looped = true
animationTrack:Play()
local numberOfLoops = 0
local connection = nil
connection = animationTrack.DidLoop:Connect(function()
numberOfLoops = numberOfLoops + 1
print("loop: ", numberOfLoops)
if numberOfLoops >= number then
animationTrack:Stop()
connection:Disconnect() -- 더 이상 필요하지 않을 때는 연결을 해제하는 것이 중요합니다
end
end)
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
playForNumberLoops(animationTrack, 5)

Ended
기능: Animation
AnimationTrack.Ended():RBXScriptSignal
코드 샘플
애니메이션 트랙 종료
local InsertService = game:GetService("InsertService")
local Players = game:GetService("Players")
-- 애니메이션을 위해 NPC 모델을 생성합니다.
local npcModel = Players:CreateHumanoidModelFromUserIdAsync(129687796)
npcModel.Name = "JoeNPC"
npcModel.Parent = workspace
npcModel:MoveTo(Vector3.new(0, 15, 4))
local humanoid = npcModel:WaitForChild("Humanoid")
-- 애니메이션을 로드합니다.
local animationModel = InsertService:LoadAsset(2510238627)
local animation = animationModel:FindFirstChildWhichIsA("Animation", true)
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
-- Stopped 이벤트에 연결합니다. 애니메이션이
-- 스스로 멈추거나 Stop을 명시적으로 호출할 때 발생합니다.
animationTrack.Stopped:Connect(function()
print("애니메이션이 멈췄습니다")
end)
-- Ended 이벤트에 연결합니다. 애니메이션이 세계에 완전히
-- 영향을 미치는 것이 끝나면 발생합니다. 이 경우 animationTrack:Stop을 호출한 후
-- 3초 후에 발생합니다. 이 3초 fadingOut이 적용되기 때문입니다.
animationTrack.Ended:Connect(function()
print("애니메이션이 끝났습니다")
animationTrack:Destroy()
end)
-- 실행하고, 재생될 시간을 주고, 그 다음 멈춥니다.
print("Play 호출")
animationTrack:Play()
task.wait(10)
print("Stop 호출")
animationTrack:Stop(3)

KeyframeReached
사용되지 않음

Stopped
기능: Animation
AnimationTrack.Stopped():RBXScriptSignal
코드 샘플
애니메이션 트랙 정지
local function yieldPlayAnimation(animationTrack, fadeTime, weight, speed)
animationTrack:Play(fadeTime, weight, speed)
animationTrack.Stopped:Wait()
print("애니메이션이 정지했습니다")
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
yieldPlayAnimation(animationTrack, 1, 0.6, 1)

©2026 Roblox Corporation. Roblox 및 Roblox 로고, 'Powering Imagination'은 미국 및 기타 국가 내 당사의 등록 및 미등록 상표입니다.