Slow down the rotation speed of an NPC

  1. What do you want to achieve? Keep it simple and clear!

I want to slow down the rotation speed of my NPC

  1. What is the issue? Include screenshots / videos if possible!

When the player is too far of the NPC, the NPC have to go back to his start position but he turn around too fast.
Here is a video of the problem Rotation problem.wmv (2.2 MB)

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried to put a bodyangularvelocity into the humanoidrootpart , I look for solution but the only thing I found it is about player rotation speed (I tried to script something with what I found but I just can’t figure it out)

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Is there anyway to fix that ?
this is the following script I use

local Oldpos = script.Parent:WaitForChild("HumanoidRootPart",2).Position
local function findPlayer()
	for i,v in pairs(game.Players:GetPlayers()) do
		if not v.Character then return end
		if v.Character:FindFirstChildOfClass("Humanoid") then
			if v.Character:FindFirstChild("HumanoidRootPart") then
				local Hum = script.Parent:FindFirstChild("Humanoid")
				local vsRoot = v.Character:FindFirstChild("HumanoidRootPart")
				if Hum and vsRoot then
					if script.Parent:FindFirstChild("HumanoidRootPart") then
						local Root = script.Parent:FindFirstChild("HumanoidRootPart")
						if (Root.Position - vsRoot.Position).Magnitude <= 100 then
							Hum:MoveTo(vsRoot.Position)
							if script.Parent:FindFirstChild("Follow") then
								script.Parent:FindFirstChild("Follow").Value = true
							end
						else
							Hum:MoveTo(Oldpos)
							if script.Parent:FindFirstChild("Follow") then
								script.Parent:FindFirstChild("Follow").Value = false
							end
							return Hum,true
						end
					end
				end
			end
		end
	end
end


spawn(function()
	while true do
		wait()
		if script.Parent:FindFirstChild("Humanoid").Health > 0 then
			findPlayer()
		end
	end
end)
1 Like

Is something wrong with my question or something not clear it is been 4 days (no replies :persevere: )

1 Like

I don’t think there is anything wrong,

I’m pretty sure there is no way to easily fix this, which contributes to the reason why people haven’t answered quickly.

I personally have never messed with npc movement before so whatever I say could be inefficient or just wrong.

Looking at MoveTo it looks like there is no variable you can change to fix this.
One possible quick fix that might work is slowing down the humanoids walk speed while rotating, although this is probably not exactly what you want.

The difficult fix that I’d suggest is: get rid of MoveTo all together, and create your own MoveTo Function. You would loop through the function every renderstep with a high renderpriority, and base position and rotation off of os.time() using SetPrimaryPartCFrame().

If you want me to go through this and learn it with you I’d be happy to.

And if someone who knows more about this than me wants to interfere please do.

thanks for your replies, I will be grateful if you help me because I don’t know much about NPC too. So of course, the ‘Easy way’ don’t work, I already try it. So I will try to create a my own MoveTo function as you say. But I have no idea how to start.

Sounds like a system I need to implement in future projects, I’d be glad to go over it with you through discord or something similar.

1 Like

Hiwi!
Well I made some NPC systems, for monsters that chase, animated or custom rigs to be used by players.
By reading ur script quickly, I think that is doing what its supposed to do, the local Oldpos, doesnt contain a CFrame aimin to that position the creature takes when u are far away?

Maybe you should first implement more “skills” for the creature in order to really find a problem. Or what do u want that creature to do? Just turn?

EDIT: I would suggest, you should rebuild the script… Place a part that will be considered as the “spawn” point for the creature, and let the creature to walk back there when its far from you. Use that while loop to feed constantly your player position for the creature to follow you. Place a part too and make him walk to that part by an easy command on Commands Bar, for ur tests

Ah sorry, I think my question wasn’t clear! :sweat_smile:
The NPC follow well the player and get back to his old position when the player get too far and I already add skills. As you can see here Skills.wmv (4.3 MB)

The problem is the NPC rotate to follow the player way too fast and when I pass under him, beside rotating, the HumanoidRootPart teleport to face the player and his leg propel the player outside the map. It is really weird you can see the bug I want to fix here Bug ((.wmv (3.7 MB)

1 Like

Of course man, add me on discord : Flash_OG5#6315

Ohh I got it! Your NPC is going great! yup you only need to fix some details. What about making it rotate by walking and rotation the upper torso slightly?

That happens a lot with giant Humanoids, making the legs not collidable is not an option with it right?
Your NPC is going great, I tought you were stucked with something simple, but its going great! good luck :3

1 Like

Yeah I will try that but the animation is not done yet it is just a visual. thx for your help!

Sorry to bump this idea back up. I just want new comers to know how to make slower rotation with Roblox’s Physics.

A simple fix to this is to use an invisible medium sized noncollidable part located right on top of the HumanoidRootPart position with a weld constraint being welded to the HumanoidRootPart.

This part needs to be parented to the NPC model and should act as if another body part. I’d call this part “SlowRotationWeight”. From now on the NPC should be rotating more slowly because of block Physics.

1 Like

Hey I know its been awhile since this topic is covered but what kind of weld do you mean to be use, and how big the “SlowRotationWeight” is? Also is the this “SlowRotationWeight” part completely above the HumanoidRootPart?

The part can be like 4 by 2, by 2 studs. And you use a weld constraint. Its just an invisible part parented to the character so they rotate slower.