How do you check if an npc is moving or not?

Allow me a moment to test it out.

I think I know why it runs sometimes. My theory is that the velocity from the idle animation is causing the HumanoidRootPart to move a bit.

That might be the issue. I used HumanoidRootPart in attempts to avoid that issue. Here are my results testing on the dummy.
https://gyazo.com/05223f9709e6d0affc6cd60a27a8788f

Ah actually, I take that back, I noticed something. When the game first loads, it continuously sees the HumanoidRootPart as MOVING. I am investigating right now.

@S0MBRX That’s what I’ve been doing, but it causes bugs because when the player stops moving and starts moving it will cause overriding animations sometimes. Both idle and running are looped animations, the animation won’t always play the correct animation for the last action (walking, standing).

@Volieb Yeah that’s what the problem is for me, I’m not entirely sure why this is the case but I could simply just make the Npcs jump when theyre first spawned.

@Wyzloc I figured it out.

When the HumanoidRootPart is slightly rotated, the velocity is above 0, but extremely small (like, 0.00004 small). To solve this, I made the following adjustments:

if math.floor(humanoidRootPart.Velocity.Magnitude)>0 then
    -- is moving
else
    -- not moving
end
2 Likes

This means the velocity must be at least 1. 0.5 will not trigger this, unless I adjusted it a bit more.

Yeah that solved the issue, I can’t believe it took that long to fix something so simple Roblox is weird.

Glad you were able to figure it out. Good luck and goodnight :grin:

oh yes i have had these issues in the past managing user input with animations and scripts can be hard but you can use logic to make sure animations/scripts dont run simultaneously sorry for the late reply its really late here and im gonna sleep but yeah glad u got a solution goodnight

Sorry about that, the humanoid doesn’t have an AssemblyLinearVelocity property, I was thinking of their root.

1 Like