How to animate npcs by CFrame easily?

Motor6D is too hard for me to know what is going on

Trial and error. I’ve been making procedural animation scripts with Motor6D for a while, so ill tell you what I know. (assuming R6)

Limbs are weird.
They normally don’t have the same rotations you would expect them too.
Use Motor6D.C0 to change the offset of the motor. Store the original C0 value, then add your new offset:

local C0 = Motor6D.C0
Motor6D.C0 = C0 * CFrame.new(0, 0.5, 0)

(this would move the limb 0.5 studs up)

For making oscillating or moving offsets, use math.cos and math.sin. They’re a bit more complicated. They both return values from -1 and 1, and can be used for movement. Example:

local C0 = Motor6D.C0
Motor6D.C0 = C0 * CFrame.new(0, math.sin(x * y) * z, 0)

X would be an incremental value, like tick() or something, Y would be the speed, and Z would be the offset (like -1 * 0.5 would be -0.5)
So this code, moves the limb -0.5, to 0.5 studs up and down over time.

Hope it helped.

2 Likes

That is unfortunate, wish someone could make a plugin similar to Roblox default animation and exports out keyframes with a script inside it.

Your answer definitely helped though.

I’ve actually made a module that can play KeyframeSequences, I don’t update it, but it’s made to run on the client and to replicate roblox animations.
https://cdn.discordapp.com/attachments/1095408441926893581/1095408442321149983/KeyframeSequencePlayer2.rbxm

local KFSP = require(path.to.kfsp)
local Animator = KFSP.newAnimator(characterRig)
local Track = Animator:LoadAnimation(path.to.keyframesequence)

Track.Looped = true
Track:Play()
Track:AdjustSpeed(2)
2 Likes

Oh my god you are a lifesaver, I will be using it nnow

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