요약
메서드
ApplyJointVelocities(motors: Variant):() |
GetTrackByAnimationId(animationId: ContentId):AnimationTrack? |
LoadAnimation(animation: Animation):AnimationTrack |
RegisterEvaluationParallelCallback(callback: function):() |
StepAnimations(deltaTime: number):() |
이벤트
AnimationPlayed(animationTrack: AnimationTrack):RBXScriptSignal |
상속된 멤버
API 참조
속성
메서드
ApplyJointVelocities
Animator:ApplyJointVelocities(motors:Variant):()
매개 변수
motors:Variant |
반환
()
GetTrackByAnimationId
매개 변수
animationId:ContentId |
코드 샘플
ID로 애니메이션 트랙 가져오기
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ANIM_ID = "rbxassetid://2515090838"
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
-- 캐릭터의 humanoid에 Animator 객체가 포함되어 있는지 확인합니다.
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
-- 새로운 애니메이션 인스턴스를 생성하고 애니메이션 자산 ID를 할당합니다.
local kickAnimation = Instance.new("Animation")
kickAnimation.AnimationId = ANIM_ID
-- 애니메이션을 animator에 로드합니다.
local kickAnimationTrack = animator:LoadAnimation(kickAnimation)
-- 짧은 지연 후 애니메이션 트랙을 재생합니다.
task.wait(3)
kickAnimationTrack:Play()
local startTime = tick()
RunService:BindToSimulation(function(deltaTime: number)
if tick() - startTime > 1 then
-- ID로 트랙을 가져오고 재생을 중지합니다.
local kickTrack = animator:GetTrackByAnimationId(ANIM_ID)
if kickTrack and kickTrack.IsPlaying then
kickTrack:Stop()
end
end
end)LoadAnimation
RegisterEvaluationParallelCallback
StepAnimations
매개 변수
반환
()
코드 샘플
로블록스 스튜디오에서 애니메이션 미리 보기
local RunService = game:GetService("RunService")
local function previewAnimation(model, animation)
-- AnimationController와 Animator 찾기
local animationController = model:FindFirstChildOfClass("AnimationController")
local animator = animationController and animationController:FindFirstChildOfClass("Animator")
if not animator then return end
-- 애니메이션을 로드하여 AnimationTrack 생성
local track = animationController:LoadAnimation(animation)
track:Play()
-- 애니메이션 미리 보기
local startTime = tick()
while (tick() - startTime) < track.Length do
local step = RunService.Heartbeat:wait()
animator:StepAnimations(step)
end
-- 애니메이션 중지
track:Stop(0)
animator:StepAnimations(0)
-- 관절 초기화
for _, descendant in pairs(model:GetDescendants()) do
if descendant:IsA("Motor6D") then
local joint = descendant
joint.CurrentAngle = 0
joint.Transform = CFrame.new()
end
end
end
local character = script.Parent
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
previewAnimation(character, animation)이벤트
AnimationPlayed
매개 변수