Hi, I have followed a tutorial and have an NPC that follows the player - it works fine, but I want the NPC to stand behind the player and to the right (instead of directly behind the player).
How would I do this? I have tried adding Vector3.new(x,y,z) to the destination, but it doesn’t seem to work.
local function getPath(player, destination)
local pathData =
{
AgentRadius = 1,
WaypointSpacing = 4
}
local newPath:Path = PathService:CreatePath(pathData)
newPath:ComputeAsync(humRp.Position, destination)
return newPath
end
And this is what makes the NPC walk
local function walk(destination: Vector3)
if not target then return end
if not target.Character then return end
path = getPath(destination)
local currWaypoint = 1
if DISPLAY_PATH then
displayPath(path:GetWaypoints())
end
humanoid:MoveTo(humRp.Position)
local oldPath = path
if isPlayerClose() then
else
if path.Status == Enum.PathStatus.Success then
for index, waypoint in pairs(path:GetWaypoints()) do
if index == 1 then
continue
end
if oldPath ~= path then
break
end
local detected = detectParts()
if detected then
local normal = detected.Normal
humanoid:MoveTo(humRp.Position + normal * 2)
task.wait(.15)
end
currWaypoint += 1
if #path:GetWaypoints() <= 0 then
break
end
humanoid:MoveTo(path:GetWaypoints()[currWaypoint].Position)
humanoid.MoveToFinished:Wait()
end
end
end
end
I have tried using Vector3, CFrame, it just doesn’t work when I add it (the NPC stops moving or just doesnt do anything differently) and I don’t know where to edit it.