Core animation priority and should you just change all the default animations

Hey, my aim is to make sure that when the player presses one they play an animation and then change the default idle animation.

There are a few issues though, if I change the default idle animations before or after the animation has been played, the played will still do the default idle animation until I move and go back into another idle animation. So basically the old idle animation is not stopping and the new one is not overriding it.

Then I tried to stop all animations from playing before playing the main animation and the same thing happens only there is no idle animation until you move and go back into an idle animation.

Then I tried to stop all animations and after the main animation, start the idle animation manually, which led to the player just being stuck in the idle animation even when moving.

Then I tried changing the animations priority to core and that kinda worked, but not really. The animation got messed up and the hands and legs aren’t in the right positions I suspect my idle core animation is overlapping with all the over-core animations. I couldn’t find a way to change the weight of my idle core animation so it’s lower than the walking/running animation and therefore it all is just mushed up.

Should I just make a script that changes all the default animations and set’s the priorities or is there another way?

The code:

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local userIService = game:GetService("UserInputService")
local humanoid = character:FindFirstChild("Humanoid")
local animations = game:GetService("ReplicatedStorage"):WaitForChild("Animations")
local animator = humanoid:FindFirstChild("Animator")
local animateScript = character:WaitForChild("Animate")
local combatStartAnimationTrack = animator:LoadAnimation(animations.CombatStart)
local combatIdleAnimation = animations.CombatIdle
local combatIdleAnimationTrack = animator:LoadAnimation(animations.CombatIdle)
userIService.InputBegan:Connect(function(input)
local idleDb = false

	if input.KeyCode == Enum.KeyCode.One and not idleDb then

	for i, v in pairs(humanoid:GetPlayingAnimationTracks()) do
		v:Stop()
	end
	animateScript.idle.Animation1.AnimationId = combatIdleAnimation.AnimationId
	animateScript.idle.Animation2.AnimationId = combatIdleAnimation.AnimationId
	local idleAnimationTrack2 = animator:LoadAnimation(animateScript.idle.Animation1)
	idleAnimationTrack2.Priority = Enum.AnimationPriority.Core
	
	combatStartAnimationTrack:Play()
	idleAnimationTrack2:Play()
	idleDb = true
end)

robloxapp-20241129-1736125.wmv (840.9 KB)

2 Likes

if you want any animation to overwrite other animation simply give it a higher AnimationPriority

1 Like

Understandable, but then again if I change the walking/running priority then if I try to jump the idle animation will still be higher than the default jump animation, because the jump animation. and all default animations have a core priority which is the lowest and idle is higher than core in the priority list.
So I would need to change all of the default animations. Is that what you’re suggesting? I thought there might be a way to change the priority (weight) within the core priority if that makes sense.
I think I’m missing some key concepts (

2 Likes

you can detect when the player jumps by using UserInputService.JumpRequest to stop the animation , to detect when the player land check if Humanoid.FloorMaterial is not set to Air

1 Like

Yeah, I understand that, but that would mean that I need to do that for every default animation. I thought there might be an easier way to do it

Unfortunately, I couldn’t find a way to do that like I wanted to. Still, I got it done by changing the default run / walk animations to the same animations but with the priorities idle and movement not core as the default has.

Then I added this line of code:

runService.Heartbeat:Connect(function()
	if humanoid.MoveDirection.Magnitude > 0 and idleAnimationTrack.IsPlaying then
		idleAnimationTrack:Stop()
		
	elseif humanoid.MoveDirection.Magnitude == 0 and defaultIdleAnimationTrack.IsPlaying then
		for _,v in pairs(animator:GetPlayingAnimationTracks()) do
			if v ~= defaultIdleAnimationTrack and v ~= combatStartAnimationTrack then
				v:Stop()
			end
		end
		
	elseif humanoid.MoveDirection.Magnitude > 0 and defaultIdleAnimationTrack.IsPlaying then
		defaultIdleAnimationTrack:Stop()
	 
	end
end)

Basically, it checks if I’m playing the animation while moving and stops it so it doesn’t interrupt the running animation.
And then when I need it to change back to the idle animation after pressing one it stops all animations but the new idle animation and the combat start animation (which is actually combat end xd)

Hopefully, this could help someone, if you need more clarity you can write your questions here.

you can replace the animating script with one that have the animations you want

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