ViewPortFrame Character Animation

So I’ve noticed that you can’t animate character models within a ViewPortFrame.
Doing some research, I found a post about updating Motor6D with Transform.

My problem is that my script doesn’t seem to work.

c = Character model in ViewPortFrame
proxyAnim = Table containing actual player character’s Motor6 instances

repeat
	game:GetService('RunService').RenderStepped:Wait()
	for _,v in pairs(proxyAnim) do
		c:FindFirstChild(v.Name,true).Transform = v.Transform
	end
until dead

I’ve printed both values and it outputs that it’s updating, but the character model in the ViewPortFrame isn’t changing nor are its Motor6 instances. But even changing them manually doesn’t seem to do anything in Studio. Does this no longer work or am I doing something wrong?

If this is no longer possible, I plan on simply updating all of the BasePart CFrames.

3 Likes

Insert a WorldModel into the ViewportFrame and then parent the character model to it, then you can animate it just fine.

22 Likes

I just tried that and it doesn’t seem to make any difference? Is there something extra that I need to do to enable it?

Did you attempt to play any animations on the character clone? You can’t just copy the character and hope that the duplicate automatically plays animations matching the actual character.

The gif below was set up using a ViewPortFrame and a WorldModel.

2 Likes

I copied the idle animation from my character in Studio and loaded that directly into the clone’s humanoid and played it. Nothing seems to have happened.

Can you provide an image of your setup in the explorer as well as the code you wrote?

In-Game PlayerGui:

image

function ang(x,y,z) return CFrame.Angles(math.rad(x),math.rad(y),math.rad(z)) end
local P = game:GetService('Players')
local p = P.LocalPlayer
local port = script.Parent:WaitForChild('Port')
local cam = Instance.new('Camera',script)
local anim = script:WaitForChild('Animation1')
port.CurrentCamera = cam
if not p.Character then p.CharacterAdded:Wait() end
p.Character:WaitForChild('HumanoidRootPart')
wait(1)
local c = Instance.new('Model')
for _,v in pairs(p.Character:GetChildren()) do
	if not v:IsA('BaseScript') then
		v:Clone().Parent = c
	end
end
c.Parent = port:WaitForChild('World')
cam.CFrame = c.HumanoidRootPart.CFrame*ang(0,180,0)*CFrame.new(0,0,5)
local idle = c.Humanoid:LoadAnimation(anim)
idle.Looped = true
idle:Play()

(I know there are some parts that can be improved, but I’m just doing this for testing right now.)

You’re cloning the parts of the character and putting them in a new model - there’s no humanoid to load an animation to. There also wouldn’t be any joints. (Edit: Misread “BaseScript” as “BasePart”)

Set the Archivable property of the actual character to true (it’s false by default) and then you can just call :Clone() on the player’s character.

https://developer.roblox.com/en-us/api-reference/property/Instance/Archivable

2 Likes

There actually is a Humanoid as shown here:

image
But your Archivable solution worked anyways. Thank you

1 Like

That’s my bad, misread “BaseScript” here as “BasePart” and thought it was just cloning the parts.

1 Like

:sandwich: I’d like to clarify how to make this work

  1. This is the hierarchy you need to have:
    image

  2. It’s important that your model is placed inside a WorldModel, inside your ViewportFrame.

  3. To play your animation, you need to use a Script.

  4. Inside the script you load your animationID and play your animation.

Here’s an example-script:

repeat wait() until script.Parent

local anim = script.Animation
local track = script.Parent.Humanoid.Animator:LoadAnimation(anim)
track.Looped = true
track:Play()

I hope this will help anyone in the future that is having trouble.

5 Likes