I am starting to learn NPCS and how they work tommrow. BUT before I do, I have some questions on how to make them and stuff.
-
How would I make the NPC follow players, go to certain positions effectively? I know about pathfinding but if there are any other ways to do it please tell me.
-
How would I rig NPCS, I made a dinosaur NPC today and I am wondering how I would rig it
-
How would pathArgs work?
4.How would I make npcs run animations.
I made a script on a NPC, it is supposed to be following the player but it isn’t. Here is the script
local humanoid = script.Parent:WaitForChild("Humanoid")
local NPCRootPart = script.Parent:WaitForChild("HumanoidRootPart")
local NPC = script.Parent
local PathfindingService = game:GetService("PathfindingService")
--[[local pathArgs = {
["AgentHeight"] = 13.43,
["AgentRaidus"] = 3,
["AgentCanJump"] = true
}--]]
function moveToPlayer()
local characters = game.Workspace:GetChildren("Model")
if characters ~= NPC and characters.HumanoidRootPart and characters.Humanoid then
local magnitude = (NPCRootPart.Position - characters.HumanoidRootPart.Position).Magnitude
local path = PathfindingService:CreatePath()
path:ComputeAsync(NPCRootPart.Position,characters.HumanoidRootPart.Position)
local waypoints = path:GetWayPoints()
for _, waypoint in pairs(waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid.Jump = true
end
if magnitude <= 20 then
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait(0.5)
end
end
end
end
while wait(1) do
moveToPlayer()
end