其他

roblox-npc-ai

el4cteo/roblox-skills

NPCs and enemy AI - PathfindingService (CreatePath, ComputeAsync, costs, modifiers, links, blocked paths), chase/follow loops, state machines, perception and line of sight, spawning/pooling, scaling to many NPCs. Use when creating enemies, pets, followers, shopkeepers, wave spawners, or fixing NPCs that get stuck, jitter, or lag the server.

  • 504 次安装
  • 55 星标
  • 收录于

安装命令

npx skills add https://github.com/el4cteo/roblox-skills --skill roblox-npc-ai

SKILL.md

NPCs and AI

Architecture

  • NPC logic runs on the server (authoritative targets, damage, drops). Visual extras (idle animations, nameplates, effects) can run on clients.
  • One NPC service drives all NPCs from a single loop (e.g. 5–10 Hz "think" rate, staggered), not one script + while true per NPC. Tag NPC models (CollectionService) and keep per-NPC state in a table.
  • Server-owned physics: npc.PrimaryPart:SetNetworkOwner(nil) after spawning, so NPCs don't stutter when ownership moves between nearby players (and exploiters can't push them).
  • Use Humanoid for NPCs that need walking/jumping/climbing; for simple movers (turrets, floating enemies, crowds) use an AnimationController + Animator and move with constraints or CFrames.

Pathfinding

--!strict
local PathfindingService = game:GetService("PathfindingService")