Help with mesh character NPC animation

I basically know very little about scripting. Is there a way to script a custom walking animation for a mesh character NPC? I have the idle and attack animations working but i can’t figure out how to make him walk. he just glides across the floor. ive tried everything.

1 Like

Is your NPC playable? as in can you play as the NPC?

Yes. if i use him as the startercharacter i can play as him and all the animations work fine.

Do you want the idle/run/walk to be the same for all characters?

No. I have a few different npc’s im gonna have in the game and i want a couple with different animations. Unless the only way i can do it is by giving them all the same animations.

No it is possible to change all of their animations just slightly more complicated.
I can’t really make the whole script for you as per DevForum rules, but I will give you some help.
To change the default animations, make this a localscript in startercharacterscripts.

-- connect this to a function which detects if the character has changed
	for _, playingTracks in pairs(humanoid:GetPlayingAnimationTracks()) do
		playingTracks:Stop(0)
			end
	local animateScript = character:WaitForChild("Animate")
	animateScript.run.RunAnim.AnimationId = "http://www.roblox.com/asset/?id=YOURIDHERE"        -- Run
	animateScript.walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=YOURIDHERE"    -- Walk
	animateScript.jump.JumpAnim.AnimationId = "http://www.roblox.com/asset/?id=YOURIDHERE"      -- Jump
	animateScript.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=YOURIDHERE"   -- Idle (Variation 1)
	animateScript.idle.Animation2.AnimationId = "http://www.roblox.com/asset/?id=YOURIDHERE"   -- Idle (Variation 2)
	animateScript.fall.FallAnim.AnimationId = "http://www.roblox.com/asset/?id=YOURIDHERE"      -- Fall
	animateScript.swim.Swim.AnimationId = "http://www.roblox.com/asset/?id=YOURIDHERE"         -- Swim (Active)
	animateScript.swimidle.SwimIdle.AnimationId = "http://www.roblox.com/asset/?id=YOURIDHERE" 
	animateScript.climb.ClimbAnim.AnimationId = "http://www.roblox.com/asset/?id=YOURIDHERE"
--connect this to a function which detects if the character has changed

By the way, if you want any of these animations to be default delete that particular line.
:grinning_face_with_smiling_eyes:
Also, if you want to change any other animation, press play then in workspace, look for your avatar, click the arrow next to the “animate” script, search for anything that you might want, examples include “Idle” "Run “Walk” “Swim” etc. then, click the arrow next to the value and search what the animation instance is called.
For example: run.RunAnim.AnimationId

He still seems to be gliding across the floor. it’s weird because all other animations work except for the walking animation.

Sorry for the late reply. Try changing the animation priority to “movement.” By the way, if the walking animation is the same as running that is a common problem.

Nothing seems to work for me. here is the place im using to test the character if you want to take a look at it.Weapon Showcase 2.rbxl (519.0 KB)

Try to set all of his part exept for the HumanoidRootPart from CanCollide to false

Its a mesh character so the only part in it is the humanoidrootpart.

1 Like