Hello,
I am trying to animate a custom rig (not a character rig) from Blender. I imported the animations, but I’m not sure how to animate it through script.
I tried adding a humanoid, a humanoid with an animator, and an animationcontroller and none of those worked when I used LoadAnimation().
The Animations do show in the animation editor, so it’s likely a quick fix or trick that you’d simply have to know.
2 Likes
Could we see the code you use for loading the animation? Did you use the correct animation ID? How did you upload the animation from blender (your process)?
1 Like
The code literally is as simple as it gets: SwampMonster.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Item.SwampMaster.SwampMonsterIdle):Play()
I have confirmed that the code is correct multiple times, putting it into the animation editor.
I imported it a while ago, so I’m not completely sure, although if I remember correctly I think I just made it on roblox.
1 Like
Side Note: Loading animations on the humanoid is :LoadAnimation()
is deprecated, add an Animator
instance on your humanoid and use Animator:LoadAnimation()
instead.
Try printing this out:
local anim: AnimationTrack = SwampMonster.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Item.SwampMaster.SwampMonsterIdle)
warn(anim.Length) -- if this prints out 0, it means your animation hasn't loaded in yet
1 Like
Oh yeah, I forgot about how sometimes a loaded animation can have 0 length. However, this still didn’t resolve it. Here’s what I tried:
warn(anim.Length)
local anim2 = script.Parent.AnimationController.Animator:LoadAnimation(game.ReplicatedStorage:WaitForChild('Animations'):WaitForChild("Item"):WaitForChild('SwampMonster'):WaitForChild('SwampMonsterIdle'))
warn(anim2.Length)
while anim.Length == 0 do
wait()
end
print("Animation had a length!")
anim:Play()
1 Like
So I’m assuming it passed anim.Length
and printed out that line? Could you add these lines under your while loop?
warn(anim.Length)
warn(anim.Animation)
warn(anim.Animation.AnimationId)
Also, am I right to assume that when you’ve tried to load the animation ID into your animation editor – it played just fine…?
Try setting your animation to a high priority actually and see what happens (test both Action and Action4)
1 Like
Just added those lines, everything came out perfectly. Yes I just tested it again, using the ID just printed, and works fine. Already had it set to Action4 beforehand, too.
Perhaps it’s an issue with it’s anchoring or the fact that animator is inside controller?
All the parts are unanchored, but the HumanoidRootPart is weld constrained to an anchored part.
1 Like
I think you’re doing it right – the AnimationController acts as an empty shell for the animator to do it’s thing.
Try unanchoring every part in your model…? You can also try anchoring HumanoidRootPart? I have to admit that I’ve never really used an AnimationController before, and I feel like there’s some weird quirk that can’t be found on the humanoid that I’m not aware of as well…
Really interesting, no idea what could be happening tbh.
1 Like
Unfortunately, I tried all of those, and still no animation. It could also have to do with the HumanoidRootPart and Humanoid; I’m just adding them to the model. But if that were the case I’m not sure where to go from there. I’m really surprised there’s nothing on this out there.
Actually, come to think of it, it may just be about how odd the set up is. My model doesn’t look like any of the other ones I’ve seen (I’m quite new to blender)
This is the general set up, does it look normal?
I realized that it might’ve just been poorly made or some other issue, as it was my first rig in blender. If someone else has the same issue you can message me and I can try to help.