Attempting to animate NPCs on the Client side, as the NPCs are client specific.
Was wondering if working with Velocity is the best way to do this for the running animation and so forth?
Attempting to animate NPCs on the Client side, as the NPCs are client specific.
Was wondering if working with Velocity is the best way to do this for the running animation and so forth?
Can’t you just use WalkSpeed? That is if your NPCs have a humanoid.
I can do, but is there a way to get the NPCs specific Speed?
E.g. being as they’re walking the normal animation is playing, upon their Speed becoming 0 they return to Idle? Etc.
You mean you’re trying to play animations based from the current NPC speed?
Aye, ideally the normal Players Animations but entirely client based on the NPC.
Have experimented a few different ways, none of which have seemed successful.
If you want to know the speed of the NPC, you can just do:
If NPC is walking, then WalkSpeed = 16; Play walking animation.
If NPC is running, then WalkSpeed = RunningSpeed; Play running animation.
When the NPC is done running or walking, make WalkSpeed = 0 then play idle animation.
Although there are better ways to do this, this will not require complex checks that use Velocity and other methods. This is straight to the point and you will keep track of the NPC state within your script.
The question confuses me and doesn’t fit the title. What explicitly are you looking for?
If you’re looking for speed changes, you could probably use GetPropertyChangedSignal on the Humanoid’s WalkSpeed and save it as an upvalue or set the animation speed based on this. Once that’s done, you can connect to Humanoid.Running to check when the player starts or stops moving.
The default animate script should have code you can salvage, since it already performs this kind of behaviour - I don’t remember how exactly though.
If walkspeed < 10 then the walk animation will play, else the run will play. I don’t know if this is what you want.
No no, English is confusing
Basically normal Player Animations, such as idle, walking, jumping etc. Being played on a Client NPC.
So the player enters a chunk that is loaded client side, with npcs included but the npcs are animated? Normal local and server don’t work on npcs in client
Just clone the animate script into the NPCs
Load the animation for the NPC from a client script. Loading an animation on a server-created object (such as an NPC) will only play that animation for that specific player, which sounds like what you want. The wiki page for animations suggests loading anims from the server, but that is only if you want it to replicate for all users.
You will need a Local Script, probably in the player.
In a previous project I’ve done this before. I pulled all the animation values out of the Player’s Animate script and put them in a folder called Animation inside the NPC, Then have the local script run this and you can have the NPC use all the ROBLOX player’s animations:
local animation = npc.Animation.cheer.CheerAnim --change cheer.CheerAnim to whatever animation exists in the folder
local animTrack = npc.Humanoid:LoadAnimation(animation)
animTrack:Play()
edit: I got the code that does this in this copyable place:
the localscript is in StarterPlayer.StarterPlayerScripts
Thank you!
I ended up putting a Module script inside of the NPC that is triggered via the local script.
Thank you so much!
Your welcome!