Skinned Mesh NPC won't face towards target

First time using a skinned mesh monster but basically i’ve got into blender and set his front position to be the front of the mesh and for some reason my monster wont turn towards the target it kinda just strafes (i’ve included a video to explain better + decals showing the face of the monster)

local players = game:GetService("Players")
local runService = game:GetService("RunService")

local hound = script.Parent
local humanoid = hound:FindFirstChild("Humanoid")
local houndRootPart = hound.PrimaryPart

local maxDistance = 50
local minDistance = 6.5

function findClosestPlayer()
	local playerList = players:GetPlayers()

	local closestPlayer = nil
	local magnitude = nil
	local position = nil

	for i, player in pairs(playerList) do

		local character = player.Character

		if not character then return end
		local distanceVector = (character.HumanoidRootPart.Position - houndRootPart.Position)

		if not closestPlayer then
			closestPlayer = player
			magnitude = distanceVector.Magnitude
			position = distanceVector.Unit
		elseif distanceVector.Magnitude < magnitude then
			closestPlayer = player
			magnitude = distanceVector.Magnitude
			position = distanceVector.Unit
		end
	end

	return closestPlayer, magnitude, position
end

runService.Heartbeat:Connect(function()
	local closestPlayer, magnitude, position = findClosestPlayer()

	if closestPlayer then 
		if magnitude <= maxDistance and magnitude >= minDistance then

			humanoid:Move(position)
		else
			humanoid:Move(Vector3.new())
		end
	end	
end)


1 Like

i’ve used this script in the past for r6 rigged enemies so it’s something to do with humanoid and skinned meshs
image

Have you made sure that HipHeight is set correctly as this can interfere with movement. I also noticed that you are recalaculting a new position and issuing a new Move command every heartbeat. This will be overriding the previous Move command, so it may not have time to start pivoting towards the destination (dunno wild guess this).

it seem’d to be fine with an r6 model so its not the script im pretty sure

bump as im still having this same problem

local model = workspace:WaitForChild("monster")
player= game:GetService("Players").LocalPlayer
task.wait(3) -- time for everything to load

model:SetPrimaryPartCFrame(CFrame.new(model.PrimaryPart.Position, player.Character.HumanoidRootPart.Position))

ill test the code out although im unsure how to implement the solution as im not sure how it works

Well good luck, keep in mind that is a local script.