For AI agents: the complete documentation index is available at /npc-mentality/zh/llms.txt, the full documentation bundle is available at /npc-mentality/zh/llms-full.txt, and this page is available as Markdown at /npc-mentality/zh/usage/crowd-ai.md.
  • 简体中文
  • 自然群体AI

    NPC 使用 NavMeshAgent 执行自主、自然的群体行为。

    概述

    普通 NPC:
      移动到目标点
    
    NPC Mentality:
      - 互相避让
      - 逛商店
      - 环顾四周
      - 突然停下
      - 绕道而行

    组件

    CrowdNPC — MonoBehaviour。需要 NavMeshAgent。

    字段类型默认值说明
    WanderRadiusfloat10f漫游半径(米)
    BehaviorChangeCooldownfloat3f行为切换间隔(秒)

    CrowdBehaviorType 枚举

    public enum CrowdBehaviorType
    {
        Wander, BrowseShop, LookAround,
        StopAndObserve, AvoidObstacle, Hurt, Idle
    }

    提示

    • 降低 BehaviorChangeCooldown 让行为更随机,增大则更有目的性。
    • 与 WorldTimeSystem 联动,夜晚增加 Idle 比例。
    • 与 EmotionController 结合,根据情感改变移动速度。