Animation really stiff and changing Priority wont do anything

for some reason my animation is really stiff and even when its at aciton4 it still stiff,

4 Likes

Are any other animations playing at the same time?

3 Likes

only the idle animation is playing, but idle is also at action 4 sooo

To start with, I’d like to clarify: are you caching animations or not? The cause of animation cache issue is quite common.

sorry but whats animation cachte?

My game has a lot of animations, so I use animation caching to avoid playback issues; however, this creates a problem of its own, sometimes the cache gets clogged up and the wrong animation plays (essentially the same issue you’re having).

This feature is not provided at the Roblox Studio, so it is only a personal initiative of the developer, but it can be quite useful

do you mind explaining me how i can do this?

I’m certainly no expert programmer in Studio, but I can share a few things.

Once a user is added, you need to allow some time for all the animations to load. (especially if the game has quite a lot of animations)

You can do this for example with this code:

function AnimationController:Load(character, animPath)
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if not humanoid then return nil end

	local cacheKey = tostring(character) .. "_" .. animPath
	if animationCache[cacheKey] then
		return animationCache[cacheKey]
	end
	
	local animObject = rs.Assets.Animations:FindFirstChild(animPath, true)
	if not animObject then
		warn("Didnt found animation:", animPath)
		return nil
	end

	local loadedAnim = humanoid.Animator:LoadAnimation(animObject)
	animationCache[cacheKey] = loadedAnim

	return loadedAnim
end
function AnimationController:Play(character, animPath, fadeTime)
	... --Heres ur code
end

function AnimationController:Stop(character, animPath, fadeTime)
	... --Heres ur code
end

function AnimationController:ClearCache(character) --Use this function to clear the user animation cache.
	for key in pairs(animationCache) do
		if key:match(tostring(character)) then
			animationCache[key] = nil
		end
	end
end

To establish a connection with the server, you primarily need a separate main script and a module script (this is the approach I use, though you can do it however you prefer).

--This is my own copied code

--AnimationManager(module script)
local function FindByPath(root, path) --So u need to keep all animations in one folder on server
	local current = root

	for _, name in ipairs(string.split(path, "/")) do
		current = current:FindFirstChild(name)

		if not current then
			return nil
		end
	end

	return current
end

local function GetAnimator(humanoid) --Some debug functions
	local animator = humanoid:FindFirstChildOfClass("Animator")

	if not animator then
		animator = Instance.new("Animator")
		animator.Parent = humanoid
	end

	return animator
end

local function GetCacheKey(humanoid, path) --You can do this simultaneously in code not using ts function
	return tostring(humanoid) .. "|" .. path
end

function AnimationManager:Load(humanoid, animPath)
	local key = GetCacheKey(humanoid, animPath)

	if AnimationCache[key] then
		return AnimationCache[key]
	end

	local animObject = FindByPath(AnimationsFolder, animPath)

	if not animObject then
		return nil
	end

	local track = GetAnimator(humanoid):LoadAnimation(animObject)

	AnimationCache[key] = track

	return track
end

function AnimationManager:Play(character, animPath, fadeTime, weight, speed)
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if not humanoid then
		return nil
	end

	local track = self:Load(humanoid, animPath)
	if not track then
		return nil
	end

	track:Play(fadeTime or 0.15, weight or 1, speed or 1)

	return track
end

function AnimationManager:Stop(character, animPath, fadeTime)
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if not humanoid then
		return
	end

	local track = self:Load(humanoid, animPath)

	if track and track.IsPlaying then
		track:Stop(fadeTime or 0.15)
	end
end

I hope this helps you out. However, I haven’t addressed rare cache-related issues, so you might still encounter the problem occasionally (I plan to create a more stable version after the initial release, but for normal gameplay, this suffices).

wha theee…is there another wayy?..

1 Like

I simply proposed an idea; of course, it is based solely on this code. And thats ur decision of how to make it. Maybe there are some solutions much better than mine.

where do i paste this code at?

If I were you, I’d look for an error in the animation playback order. Perhaps you have an error somewhere in the existing code that isn’t recognized as syntactic or something like that.

If nothing really helps, then I’d already be thinking about serious changes to the animation system. I wouldn’t be too scared by all this, because it seems to me the problem is somewhere nearby.

you mean the code that makes the animation play?

Yes, yes, that’s exactly it, maybe you got some rare case that you didn’t handle and now you see incorrect animation playback

this is the code i have it play, also this script is serverside

local players = game:GetService("Players")
local char
local plr
script.Parent.Equipped:Connect(function()
	char = script.Parent.Parent
	plr = players:GetPlayerFromCharacter(char)
	
end)

script.Parent.Unequipped:Connect(function()
	char = nil
	plr = nil
end)
local Animation = script.Parent.Jab

local jabsdown = script.Parent.Jabdown

script.Parent.JabRe.OnServerEvent:Connect(function(player)
	local hum = char:WaitForChild("Humanoid")
	local LoadedAnimation = hum:WaitForChild("Animator"):LoadAnimation(Animation)
	LoadedAnimation:Play()
	LoadedAnimation:GetMarkerReachedSignal("hit"):Connect(function()
		script.Parent.damage.Value = true
		script.Parent:WaitForChild("Handle").hnitboxx["glass breal"].Enabled = true
		script.Parent:WaitForChild("Handle"):WaitForChild("hnitboxx").cut.Enabled = true
		task.wait(0.1)
		script.Parent.Handle.hnitboxx["glass breal"].Enabled = false
		script.Parent.Handle.hnitboxx.cut.Enabled = false
		script.Parent.damage.Value = false
	end)

end)

script.Parent.parry.OnServerEvent:Connect(function()
	local hum = char:WaitForChild("Humanoid")
	local LoadedAnimation = hum:WaitForChild("Animator"):LoadAnimation(jabsdown)

	LoadedAnimation:Play()
	LoadedAnimation:GetMarkerReachedSignal("block"):Connect(function()
		local newinsce = Instance.new("BoolValue")
		newinsce.Parent = char
		newinsce.Name = "block"
		newinsce.Value = true
		game:GetService("Debris"):AddItem(newinsce, 1)
	end)
	

end)

First of all, every time a player attacks, you create a new AnimationTrack.

local LoadedAnimation = hum:WaitForChild("Animator"):LoadAnimation(Animation)
LoadedAnimation:Play()

You leave its parameters (which determine animation playback) at the default settings.
It’s also quite possible that your Jab and Idle animations are mixed because they have the same priority?? (since you’re creating new AnimationTracks).

I’d also add debugging to your code to understand what’s happening with each animation.

1 Like

omg thank u, you helped me find out why it was doing this and its because i had idle the same priority!!

A lot of information here.. AnimationTrack There are extended command options for playing animations. The weight, in this case, and/or priority should help.

Hard to say in this case because you said you have a custom animation. What I am pointing out is you have a lot of control over how that plays and how it blends with other animations.

local track = humanoid:LoadAnimation(anim)

track:Play()
track.Priority = Enum.AnimationPriority.Core
--[[

----
track.Priority = Enum.AnimationPriority.Priority level

Core > Action4 > Action3 > Action2 > Action > Movement > Idle > Emote

Core     .. system animations: death, platform stand, etc. --not blendable, overrides
Action4  .. highest user control) -- strong override, minimal blending with lower tracks
Action3  .. medium-high priority, can blend if equal/higher stack exists
Action2  .. mid priority, often blends unless competing with Action+
Action   .. light override, blends easily with Movement/Idle
Movement .. walk/run/jump blends often live here) --primary blended locomotion layer
Idle     .. lowest, default stance --always blended unless overridden

----
track:Play(fadeTime, weight, speed)

fadeTime .. how fast it blends in
weight   .. how strong the animation is (0–1+)
speed    .. playback speed multiplier

exp: track:Play(0.2, 0.5, 1)

0.2 = quick blend in
0.5 = half influence
1   = normal speed

--]]

Start using this stuff and you’ll never use just Play() again..
Really can fine tune how everything is flowing with these.

1 Like