teakzc/crunchywrapper
crunchyroll (ffrostfall/crunchyroll, but i forked it and it will be used here) wrapper with animation fades and motor6d support
crunchywrapper
📦 Installation
pesde add teakzc/crunchywrapper
⭐ Features
- (Exponential or Linear) Fade in and Fade out
- Motor6D support
- Strictly Typed API
- R6 only (R15 maybe soon)
Special Thanks
- Thank you to @marunima for suggesting how to add fades and how to motor6ds
- Thank you to @john_malakas for the SteelProjectsRBX/BasicCrunchyRollAnimPlayer that inspired this
- Thank you to @jiwonz for some help
Note
This uses teakzc/crunchyroll on wally (slight changes to support motor6d so use that too or fork it yourself)
wally add teakzc/crunchyroll
Documentation
export type selfprops = {
Character: Model,
Animations: { [crunchyroll.AnimationAsset]: CompleteAnimationData },
Rig: crunchyroll.Rig,
Motor6D: { [string]: Motor6D },
AnimationTracks: {
[string]: {
[string]: crunchyroll.AnimationAsset,
},
},
}
export type CustomData = {
Looped: boolean,
ExponentCurve: number,
End: boolean?,
Speed: number?,
FadeIn: number?,
FadeOut: number?,
FadeInElapsed: number?,
FadeOutElapsed: number?,
FadeOutForce: number?,
OriginalWeight: number?,
}
⚠️ FADE IN AND FADE OUT
Fade in and Fade out requires a IDLE TRACK
or else it won't work! (It uses weight to fade so it needs another track)
new(Character: Model, Rig: crunchyroll.Rig): self
Creates a animation class, where you can play tracks and update the character's motor6d. It is recommended to create new rigs for every time you do this.
AddTrack(self: self, AnimationAsset: crunchyroll.AnimationAsset, Data: AnimationData, Fade: number?, FadeOut: number?)
AddTrack takes in the animation class of a player you want to use. You have to give the function a crunchyroll.AnimationAsset
which is just crunchyroll.load_keyframe_sequence(keyframe_sequence, rig)
using the same rig for animation.new
Example:
animation:AddTrack(MyVeryAmazingAnimationAsset, {
Looped = true,
weight = 3,
priority = 1,
alpha = 0,
ExponentCurve = 3
}, .25) --Fade in time included, make sure you have an idle track too
Loop loops the track, and exponentcurve determines the fade in fade out curve.
This graph is for how ExponentCurve changes weight
RemoveTrack(self: self, AnimationAsset: crunchyroll.AnimationAsset, Fade: number?)
Remove track will set will calculate if there is remaining time left for the fade time, if there is enough the track will fade using the exponent curve defined with
(). If there isn't enough time then it will use the remaining lifespan of the animationtrack to fade out.ForceRemoveTrack(self: self, AnimationAsset: crunchyroll.AnimationAsset)
Forcefully sets the track to nil, removing it like it never existed.
UpdateMotor(self: self)
Updates the player's motor6d to match the animation from crunchyroll.
Stepped(self: self, dT: number, UpdateMotor6: boolean?)
Stepped updates the crunchyroll frame and calculates.
It is recommended to use RunService.PreSimulation
for this