How can I get my object animation working?


I have animated a TV and a rig in Moon Animator. The problem is that the TV doesn’t animate, but the rig does. I put Motor6Ds on a basepart in the TV and welded it to every part in the TV. It is not anchored. Can anyone help me out here?

4 Likes

Most scripting support posts should have code linked. Otherwise I think the issue is that, to play animations, you need an animator instance.

1 Like
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local tvScreen = script.Parent
local proximityPrompt = tvScreen:FindFirstChild("ProximityPrompt")
local glassBreakSound = tvScreen:FindFirstChild("glass break")
local animation = tvScreen:FindFirstChild("Animation")
local animationController = tvScreen.Parent.Parent.basepart:FindFirstChildOfClass("AnimationController")

local standOffset = Vector3.new(0, 0, 3.5)
local rotationOffset = 0

local function onProximityPromptTriggered(player)
	local character = player.Character
	if character then
		local humanoid = character:FindFirstChildOfClass("Humanoid")
		local rootPart = character:FindFirstChild("HumanoidRootPart")
		if humanoid and rootPart then
			local screenPosition = tvScreen.Position
			local targetPosition = screenPosition + (tvScreen.CFrame.LookVector * standOffset.Z)
			local facingDirection = CFrame.Angles(0, math.rad(rotationOffset), 0)
			local lookAtScreen = CFrame.new(targetPosition, screenPosition)
			rootPart.CFrame = lookAtScreen * facingDirection
			rootPart.Anchored = true

			local playerAnimationTrack = humanoid:LoadAnimation(animation)
			playerAnimationTrack:Play()

			if animationController then
				local tvAnimationTrack = animationController:LoadAnimation(animation)
				tvAnimationTrack:Play()
			end

			if glassBreakSound then
				playerAnimationTrack:GetMarkerReachedSignal("glass break sound"):Connect(function()
					glassBreakSound:Play()
				end)
			end

			playerAnimationTrack.Stopped:Connect(function()
				rootPart.Anchored = false
			end)
		end
	end
end

proximityPrompt.Triggered:Connect(onProximityPromptTriggered)

1 Like

You should put an animator in the animation controller and interact with the animator instead. That’s how the docs say to use it. It says that the animation controller can be used in place of a humanoid for animations1. Even for humanoids, you should use an Animator2

Refs:
1
2

1 Like

Got it, I’ll update you if it works.

OK. I don’t think it will fix the issue, though. It says it’s deprecated but it probably still works.

There might be something specific I have to do to get it to work, but we’ll see.

Also on the animator page on the documentation, it says it automatically creates an animator when you call LoadAnimation() on an AnimationController. To clear things up, is the rig’s animation separate from the TV’s?

They are both on the same animation.

Where is the animation controller?

image

I just properly rigged it, made sure I had an AnimationController with an Animator under it, and rigged everything using RigEdit.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.