Animation :Play() waits for viewmodel to be parented to camera

Just wondering if anyone knows a workaround to this:

I have a viewmodel that is parented to the client’s camera whenever in first person and parented somewhere else where it isn’t visible when otherwise. I have a function which makes my viewmodel synch animation with my character however when I play the animation it plays normally for the character BUT it is only after I zoom in to first person that the viewmodel then just starts to play the animation. Both the animation character and viewmodel animation played at the same time.

A bit startled by this since I didn’t seem to have this animation synching issue in some of my previous works. Any workaround to this so that I have the viewmodel synching animations with the character even if it’s not parented to the character? Don’t really wanna just make my viewmodel transparent and have it laying in the environment somewhere.

https://gyazo.com/660ae5f8f798840f197caa56367a66f8

1 Like

Yes I have the perfect solution for it
In your update function
you do

for i, animation in pairs(playingAnimations) do
     if animation.Character.Playing then
          animation.Viewmodel.TimePosition =  animation.Character.TimePosition
          animation.Viewmodel.Weight       =  animation.Character.Weight
     end
end

depends on the way you store ur animations

Well, that can work if I have the :Play() event being triggered only after I zoomed in. In which case I can definitely just set its time position to that of the character animation. However, both my character and viewmodel animation run :Play(track) at the same time.

function playMovement(trackName, fadetime)
	if equipped or trackName == "Sling" then
		fadetime = fadetime or .1
		
		animations[trackName]:Play(fadetime)
		
		if viewmodelAnimations[trackName] then
			viewmodelAnimations[trackName]:Play(fadetime)
		end
	end
end

It’s just that the animation of the viewmodel only begins to play (despite having the :Play() triggered) after I zoomed in. Just wanted to have it so that the animation of the viewmodel still plays in synch of the character even if the viewmodel is hidden behind the scenes.

1 Like

Ended up just having the viewmodel parented to the character in the first place and having its transparency set to 1 when player is not in first person, and then set it visible when it is zoomed.

	for _, viewmodelParts in pairs(viewmodel:GetChildren()) do
		if not viewmodelParts:IsA("BasePart") then continue end
		if viewmodelParts.Name == "Left Arm" or viewmodelParts.Name == "Right Arm" then
			if not inFirstPerson then
				viewmodelParts.Transparency = 1
			else
				viewmodelParts.Transparency = 0
			end
		end
	end

To be honest that’s bad practice, I mean if the vm animations are the same as the server ones then why not use localtransparency modifiers
unless viewmodel manipulations are different

1 Like

The similarities between the character and the viewmodel ends with the animation. I’m looking to get full control of the viewmodel since I require it on few things like manipulating its cframes and other immersive stuff. Thanks for the heads up though.

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