Idle animations on a NPC?

I am currently trying to make a stand from JoJo’s bizarre adventure, but I am stuck on the Idle Animation. The idle animation is programmed with the position data, it isn’t there otherwise without the idle animation, but whenever I play the Idle Animation it begins, but it goes from position that its supposed to be in but it then loops back and basically does a twitching movement.
https://gyazo.com/1caa55631fe67e1d745a7e1a202a731b

Any help is appreciated!

2 Likes

The opening to your thread is a little jumbled but I believe this is merely a problem with the animation you’re running on the NPC rather than anything having to do with the scripts. Perhaps you’d like to improve on the animation. Are you able to show what at least three loops of the animation looks like on the animation editor?

1 Like

If you’re firing AnimationTrack:Play() multiple times before the animation can finish, it can cause that twitching movement.

If that is not the case, another possibility is what @colbert2677 said. Your animation does not end on the same keyframes that the animation started on. To fix this, copy and paste the absolute beginning animation keyframes to the end of the animation. You might have to move some stuff around.

1 Like

My bad for responding late, completely forgot about this, but I set the animation to a loop, so thats not what is causing it. Heres a picture of the animation with keyframes, but its just one millisecond.


https://gyazo.com/3ed5cfd2d25e455e749e3c6d8a298ed5

1 Like

I read a little bit more into what you said, and I did that but the result was a bit better but the exact same
https://gyazo.com/90db9899696fb0561407227504b75856

1 Like

Create an Animate script for your NPC.

Code Sample

local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")

local Animations = {IDLE ANIMATION ID,otheranimid,otheranimid2}

function playAnim(animation)
      for i=1,#Animations do
            if i == animation then
                 local a = Humanoid:LoadAnimation(Animations[animation])
                 a:Play()
            end
      end
end

function running(spd)
      if spd < 0.75 then
          playAnim(1)
      end
end

Humanoid.Running:Connect(running)

Edits: Improved and fixed code, bold-ed some text
NOTE: Remember that you should wait for the track to finish before restarting it (I have not included this in my code so that should be noted).

1 Like

I don’t know what animation editor that is. However, I can only be sure that it isn’t the problem if you show me the animation track looping while the editor is still open.

2 Likes

you set your animation to loop but is your animation really a loop?

the problem might be that you keyed your animation in a way that you aren’t interpolating back to the original position. this will cause the animation to jump back to the original position, which is what it looks like in the gif.

here's an example:

KjKdFFP1Jc

i don’t have any experience using moon animator and maybe it has its own functions to do this but in the normal plugin you would do:

this

HhkVq7n4XQ

i got rid of the jumping effect by making the last key of the animation into the resting position so that the animation interpolates back to it.

This isn’t an animation being replayed over an over, its looped in the animation editor.

I don’t want it to interpolate, I only want it to stay in the position without making use of manually setting the position and rotation of each part in a script, as its much easier in a animation instead.