Problem with model and animations

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to make a script that plays a run animation whenever an NPC is moving
  2. What is the issue? Include screenshots / videos if possible!
    Whenever the NPC is touching the ground and the animation is playing, it sort of interacts weirdly with the ground being moved occasionally and shaking weirdly. This happens even if I’m not manually moving the NPC in any way. This might not help a lot, but I also noticed that if I try moving the NPC with MoveTo without any animation playing, it looks like its getting stuck on something and stops moving altogether after a few steps but if I look closely I can see it shaking.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve made sure that no animations are playing at the same time or overriding the run animation. I also checked with different animations, so this isn’t and issue specifically with the animation I’m using. I’ve been trying to find a fix on dev forum.

I’m handling everything on a server script
This is what I’m doing to figure out whether the NPC is moving or not:

if math.floor(HumanoidRootPart.Velocity.Magnitude)>0 then
	--Is moving
else
	--Is not moving
end

This is what it looks like when I’m not moving the NPC:


For when I am moving it, its about the same thing but with less involuntary movement and visible shakiness

Thanks!

3 Likes

Anyone knows what might be the problem?

try using Humanoid.MoveDirection.Magnitude > 0 instead of math.floor(HumanoidRootPart.Velocity.Magnitude)>0 .
make sure to run/stop the animation too

also, why do you need a math.floor()? im not entirely sure but i think HumanoidRootPart.Velocity.Magnitude>0 works too.

1 Like

Using Humanoid.MoveDirection.Magnitude > 0 instead of math.floor(HumanoidRootPart.Velocity.Magnitude)>0 doesn’t work altogether because MoveDirection doesn’t work with NPCs.

I’m using math.floor() because I saw a devforum post saying that if the HumanoidRootPart is slightly rotated the velocity is above 0 and it didn’t seem to break the script.

The main issue I have is with the way the NPC twitches and also gets moved randomly when the animation is playing.

is there anything that moves or is pushing the NPC? I’ve never heard of something moving randomly when playing animations.

1 Like

Nothing from the script and no invisible objects, just what you see. The NPC is an R6 model. I’ve tried taking the NPC into a different game file to make sure no other scripts could be interfering and there was the same outcome.
Also I think I mentioned this in the original post, but if there is no animation playing when the NPC tries moving through MoveTo it can’t really move, almost as if its getting stuck in something. Like it takes a few steps and then stops, but still visibly twitching. I already made sure the MoveTo isn’t expiring from the 8 second timer.

The HumanoidRootPart, or HRP for short, shouldn’t be twitching or anything if the NPC is not moving. One thing that comes to mind is AssemblyLinearVelocity which is the newer Velocity basically. Velocity was depreciated.

If you set HRP.Transparency to 0 it might help you see what is happening as well.

1 Like

I’ve switched the Velocity part to AssemblyLinearVelocity earlier, it continued detecting whether the NPC is moving or not correctly. So that works good
This is what I can see if I put the HRP.Transparency to 0 (Note that this is with me playing the animation manually, without moving the NPC or trying to detect if the NPC is moving or not):

The movement that you see is also only happening when I’m playing the animation

Is the swords CanCollide property off?

No, I tried turning it off and it made no difference.

Anyone else got any ideas what might fix this?

The HRP is bobbing up and down. It’s generally not supposed to do that.

You could try

if math.floor( (HumanoidRootPart.AssemblyLinearVelocity * Vector3.new(1,0,1)).Magnitude )>0 then
	--Is moving
else
	--Is not moving
end

Yeah I’ve no idea why its bobbing like that, I tried the new script and it seems to give thee same outcome.

The problem is fixed now. Turning collision in the legs off and putting hip height to 2 seems to have fixed it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.