[v1.3.0.3] [Module] BetterAnimate alternative to Animate script

3 Likes

Update 1.3.0.2


:new_button:Added:

  • Types now can be accessed directly from main module (BetterAnimate)
  • Function: BetterAnimate.GetClassesPreset(Index)
 -- How to use: 
BetterAnimate.New(Character):SetClassesPreset(BetterAnimate.GetClassesPreset("R15"))
  • Propertie: BetterAnimate.PresetsTag
-- How to use: 
ModuleWithAnimationsPresets:AddTag(BetterAnimate.PresetsTag)

:hammer:Fixes:

  • :PlayToolAnimation() now calls :StopToolAnimation() on every use
  • Minor code fixes

:white_question_mark:Upcoming

  • Open source code on Github: (Live?: :white_check_mark:)
  • Devforum page improvements: (Live?: :white_check_mark:)
2 Likes

Hi! Nice work on the new module update but there is a slight problem,
When the humanoid changes it’s movedirection the animation pauses for a few seconds again with multiple animation instances playing.

Example :

I will try and record this later but I am on a different device

here are my code snippet settings →

CharacterController.lua

function manager:UpdateMovementState()
	local MyAnimator = self.MyAnimator :: BetterTypes.BetterAnimate
	local WalkSpeed = self.Humanoid.WalkSpeed

	local function Update(self) : () -> ()
		if WalkSpeed <= 12 then
			MyAnimator.FastConfig.AnimationPlayTransition = 0.3
			MyAnimator:SetClassAnimationSpeedAdjust("Run", 12)
			
			
			MyAnimator:SetClassPreset("Run", CharacterStates.Walking)
			
		elseif WalkSpeed >= 16 then
			MyAnimator.FastConfig.AnimationPlayTransition = 0.2
			MyAnimator:SetClassAnimationSpeedAdjust("Run", 21)
			
			
			MyAnimator:SetClassPreset("Run", CharacterStates.Sprinting)
			
		end
	end

	table.insert(self.Connections, self.Humanoid.Changed:Connect(function()
		Update(self)
	end))
	
	table.insert(self.Connections, self.Humanoid.AttributeChanged:Connect(function(Attribute)
		if Attribute == "IsSprinting" then
			Update(self)
		end
	end))
end

Settings

FastConfig = {
		R6ClimbFix = true, -- For R6
		EmoteIngnoreEmotable = false,
		AnimationSpeedMultiplier = 1,
		AnimationPlayTransition = 0.35,
		AnimationStopTransition = 0.15,
		ToolAnimationPlayTransition = 0.3,
		ToolAnimationStopTransition = 0.75,
		WaitFallOnJump = 0.3,
		DefaultAnimationLength = 5,
		DefaultAnimationWeight = 10,
		AnimationPriority = Enum.AnimationPriority.Movement,
		ToolAnimationPriority = Enum.AnimationPriority.Core,
	},

_Class = { -- Class ~= State 
		Inverse = { -- When inverse animation work
			Walk = true, 
			Run = true, 
			Climb = true,
		},

		Emotable = { -- When emotes can be played
			Idle = true,
			Emote = true
		},

		AnimationSpeedAdjust = { -- Humanoid.WalkSpeed / AnimationSpeedAdjust = AnimationSpeed
			Walk = 9,
			Run = 12,
			Climb = 6, -- (Humanoid.RigType == Enum.HumanoidRigType.R15 and 4) or 12, -- R6 and R15 speed must be different (roblox's skill issue)
			Swim = 10,
		},
		
		DirectionAdjust = { 
			Swim = CFrame.Angles(math.rad(90), 0, 0), -- Fix for swim
		},
		
		SwitchIgnore = {
			Jump = true,
		},
		
		SpeedRange = NumberRange.new(
			0.4, 
			9
			--[[
				-math.huge - 0.4 == Idle
				0.4 - 9 == Walk
				9 - math.huge == Run
			]]
		),
		
		TimerMax = { -- Wait until play random animation from same class
			Idle = NumberRange.new(5, 8),
		},
		
		Timer = {
			Idle = 0,
		}
	},
	
	_Inverse = {
		Enabled = true,
		
		Directions = {
			BackwardRight = true, 
			BackwardLeft = true, 
			Backward = true,
			Down = true, -- For climb
		}
	},
	
	_Animation = {},
	
	_Events_Enabled = {
		NewMoveDirection = true,
		NewState = true,
		NewAnimation = true,
		KeyframeReached = true,
	},

but errors aside, This module by far is the best player animation handler, It helped me save ALOT of time.

Another example →
Moving / Rolling that uses vector force

and it also appears to look like the module might have been initialized twice →
image

Thank you, I appreciate it😄.


I found out what causing your problem, its technically not BetterAnimate issue.

BUT i added new Propertie (MyAnimator.FastConfig.SetAnimationOnIdDifference) special for your situation (if you don’t wan’t to update your code logic).
I would advise against using Humanoid.Changed without any checks, since every Humanoid.MoveDirection updates it causes an update, In your case it is better to use:

Humanoid:GetPropertyChangedSignal(`WalkSpeed`):Connect(function() Update(self) end)

BetterAnimate can’t initialized twice, unless you do so. If you are sure that there is some error here, then please provide the code

Update 1.3.0.3


:new_button:Added:

  • FastConfig Propertie: FastConfig.MoveDirection
-- How to use: 
MyAnimator.FastConfig.MoveDirection = Humanoid.MoveDirection --> Override velocity MoveDirection with your own
MyAnimator.FastConfig.MoveDirection = nil --> Disable Override (Disabled by default)
  • FastConfig Propertie: FastConfig.SetAnimationOnIdDifference
    New animation (Instance) will play if Animation.AnimationId is not not equal to the old one

:hammer:Fixes:

  • Minor code fixes
1 Like

Thanks for the reply, I will come back to you when I add the changes!