Class NPCGroup
Coordinates a pack of NPCs that fight together. Provides shared state so individual NPC brains can make group-aware decisions via the behavior tree or state machine.
Shared state includes:
- Group target — the enemy the group is focusing.
- Lowest-health member — so healers know who needs help.
- Alive member count — for pack-wipe / rally logic.
- Combat flag — whether any member is in combat.
Place this component on an empty GameObject near the pack spawn point. Assign members in the inspector or call AddMember(AIController, NPCGroupRole) at runtime. Each member's Group is set automatically.
public class NPCGroup : MonoBehaviour
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourNPCGroup
- Inherited Members
-
MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.didStartMonoBehaviour.didAwakeMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.GetComponent<T>()Component.TryGetComponent<T>(out T)Component.GetComponentInChildren<T>()Component.GetComponentsInChildren<T>()Component.GetComponentInParent<T>()Component.GetComponentsInParent<T>()Component.GetComponents<T>()Component.GetComponentIndex()Component.CompareTag(TagHandle)Component.transformComponent.transformHandleComponent.gameObjectComponent.tagObject.GetEntityId()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.ToString()Object.nameObject.hideFlags
Fields
FocusTargeting
[Header("Targeting")]
[Tooltip("When true, all DPS members share the tank's target.")]
public bool FocusTargeting
Field Value
KiteRotationSpeed
[Tooltip("Degrees per second the Kite tactic rotates the group ring.")]
public float KiteRotationSpeed
Field Value
Tactic
[Header("Pack Tactics")]
[Tooltip("How the group coordinates spatial positioning around the target during combat.")]
public PackTactic Tactic
Field Value
TacticOrbitRadius
[Tooltip("Base orbit radius for pack tactic positioning (meters from target).")]
public float TacticOrbitRadius
Field Value
Properties
AliveMemberCount
Number of members currently alive.
public int AliveMemberCount { get; }
Property Value
GroupTarget
The group's shared combat target. Typically set by the tank or by whichever member first enters combat.
public Transform GroupTarget { get; set; }
Property Value
- Transform
IsInCombat
True if any member is in an attacking state.
public bool IsInCombat { get; }
Property Value
LowestHealthMember
The member with the lowest health percentage. Updated every evaluation. Healers can read this to decide who to heal.
public AIController LowestHealthMember { get; }
Property Value
LowestHealthPercent
Percentage (0-1) of the lowest-health member's HP.
public float LowestHealthPercent { get; }
Property Value
MemberCount
Total number of members (alive or dead).
public int MemberCount { get; }
Property Value
Members
Read-only access to the member list.
public IReadOnlyList<NPCGroupMember> Members { get; }
Property Value
Methods
AddMember(AIController, NPCGroupRole)
Adds a member at runtime and links the group reference.
public void AddMember(AIController controller, NPCGroupRole role = NPCGroupRole.DPS)
Parameters
controllerAIControllerroleNPCGroupRole
AlertGroup(Transform)
Signals the entire group that combat has started with the given target. Each member that isn't already fighting will transition to its attacking state.
public void AlertGroup(Transform enemy)
Parameters
enemyTransform
GetMemberByRole(NPCGroupRole)
Returns the first member with the given role, or null.
public AIController GetMemberByRole(NPCGroupRole role)
Parameters
roleNPCGroupRole
Returns
RemoveMember(AIController)
Removes a member from the group.
public void RemoveMember(AIController controller)
Parameters
controllerAIController