Why are my custom animations slow?

  1. What do you want to achieve?
    We’re having a friendly Halloween competition inside a discord group I’m apart of.
    :jack_o_lantern:
    I’m trying to make a horse that can run on ScriptBuilder or any other game for that matter.
    As such, I can not rely on Roblox’s default Animation object.
    I’m trying to make a custom function that can play a KeyFrameSequence
    :upside_down_face:
    Expectation:
    (Yes, I know, I’m a terrible animator. This is kinda a proof of concept)

  2. What is the issue?
    Reality:

  3. What solutions have you tried so far?
    I’ve tried two different ways to ease the animations.
    First way is by lerping

ongoingTransforms = {}

local steppedRun = game:GetService('RunService').Stepped

function ease(speed,firstCF,lastCF,motor,increment)
	speed = speed*.5
    ongoingTransforms[motor] = false
    increment = 1/(speed*59)
    for number = 0, 1, increment do
        steppedRun:Wait()
        motor.Transform=firstCF:lerp(lastCF, number)
    end
    ongoingTransforms[motor] = true
    while ongoingTransforms[motor] and steppedRun:Wait() do
         motor.Transform = lastCF
    end
end

The second way is by trying to use TweenService




loopingMotors = {}

function playOnMotor(motor,cframe,speed)
	
	if not loopingMotors[motor] then
		
		loopingMotors[motor] = Instance.new('CFrameValue')
		loopingMotors[motor].Value = motor.Transform
		
		game:GetService('RunService').Stepped:connect(function()
			motor.Transform = loopingMotors[motor].Value
		end)
		
	end
	
	local TweenService = game.TweenService
	 
	local goal = {}
	goal.Value = cframe
	 
	local tweenInfo = TweenInfo.new(speed,
									Enum.EasingStyle.Circular )
	 
	local tween = TweenService:Create(loopingMotors[motor], tweenInfo, goal)
	
	tween:Play()

end

Both of those methods basically resulted in the same thing.

I’ve also tried using spawn() to multitask different parts of the code.

I couldn’t get any improvements.

You’re free to check out the full code for yourself, but I must warn you that while the code is not completely illegible, I never intended for anyone other than myself to look through it.

Also, as a side note, I know that Motor6D.Transform does not replicate.
To get by that, I’m probably going to have the animation script be a localscript that is given to every player by a modulescript.

Here’s just the code:
https://pastebin.com/raw/nGVMWZfj

Here’s a .rbxm file that contains the horse and the code:
dispeller’s Epic Horse.rbxm (11.8 KB)

Helpful informational links:
https://developer.roblox.com/en-us/api-reference/class/KeyframeSequence
https://developer.roblox.com/en-us/api-reference/class/Keyframe
https://developer.roblox.com/api-reference/class/Pose

Thank you for reading! Any positive feedback would be appreciated.
:grin:

5 Likes

I am not very experienced with animating, but have you tried using a very small number for the speed variable in the TweenService example?

Side Note: I am pretty sure spawn() has a built in 0.3 second delay so I would use coroutines instead.

2 Likes

Thanks for the suggestion.
I tried using coroutines but to no effect.

I’ve made some minor progress.
(And a new animation)

Expectation:

Reality:

Not sure what animator plugin your using, but maybe try using the Beta version of the plugin that got released like a week ago? Lots of useful features in it.

1 Like

I’m using the one that’s in Roblox studio by default.
The animator plugin shouldn’t make a difference.
What I’m trying to do is play a KeyframeSequence directly without the use of an Animation object.

EDIT: misplaced word

1 Like

I think that the issue is that it’s doing this really fast

Whereas the normal animation is doing all the Poses all at once…

I think I’m just not multithreading the poses properly…

Also, I’m going to edit the main post to include links to things that might be informational

2 Likes

Im having this exact same problem. not just on custom rigs but the player rigs too. its slowed down my progress alot recently.

INFO: Im using the regular roblox animator, and tried many rigs. in the animator plugin the animation runs smoothly and exactly as i like it, but when i run the animation it appears slow, jumpy, but also for me the rig sinks into the ground? yes i have the correct humanoid hip height settings but still the problem happens everytime i run the game.

i would REALLY appreciate if someone could help, thanks.

1 Like

oh and btw im not doing any custom keyframe player like him, for me i have the exact same result when i try to call the animation service

I have this exact problem. I am trying to animate a custom rig only using KeyframeSequences, and the Tweens are slow and delayed like this. However, I made a plugin myself that makes a ModuleScript to animate a custom rig.

2 Likes

Sorry to bump the topic again, but I’ve completed a plugin that converts KeyframeSequences into standalone ModuleScripts. Now, I will point out, it’s not perfect, and the results (the animations) are a little faster than they should be. Anyways, with the ModuleScript, you get the Play() function and the Stop() function when you use the LoadAnimation(Rig) function. The Rig value is the most common parent of the custom rig.

Anyways, here is the plugin: Keyframe Sequence to Module - Roblox

This was intended only for custom rigs, not R15 or R6.

Use wisely!

3 Likes