Target
A class in Root.Township, Alta.Intelligence.
A networked thing that AI creatures can sense and attack, with optional health and interactable links. Only active on the server: on clients it disables itself (and by default its GameObject).
- Listed in Creatures and AI
- Inherits or implements
NetworkEntityBehaviour,ITarget,ITargetPointer - Derived types
Agent,PlayerCharacterTarget
Constructors
| Member | What it is |
|---|---|
Target() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
5 private and internal fields
| Member | What it is |
|---|---|
private HealthObject healthObject | The target's health; when it is destroyed the target is marked dead. |
private SenseSetup[] initialSenses | Senses applied when the target initializes on the server. |
private Interactable interactable | The target's Interactable, if any. |
private bool isObjectDisabledOnClient | When true (the default), clients turn the whole object off. Targets only run on the server. |
private BasicSenseSet senses | Server: the sense set built from initialSenses, exposed as Senses. |
Properties
| Member | What it is |
|---|---|
virtual Vector3 GroundPosition { get; } | The position used for distance checks. The transform position unless a subclass overrides it. |
HealthObject HealthObject { get; } | The HealthObject set in the inspector, if any. Its destruction marks the target dead. |
Interactable Interactable { get; } | The Interactable set in the inspector, if any. |
virtual bool IsAlive { get; private set; } | True until the linked health object is destroyed. |
bool IsInitialized { get; private set; } | True once server-side initialization has run. Stays false on clients. |
string Name { get; } | The entity's identifier and original name, joined with a dash, for logs. |
virtual Vector3 Position { get; } | The target's world position. The transform position unless a subclass overrides it. |
BasicSenseSet Senses { get; } | Server: the sense set built from the inspector's initial senses. Null on clients. |
StatManager StatManager { get; } | The health object's stat manager, or null if there is no health object. |
virtual Transform Transform { get; } | The transform AI should aim at. This object's own transform unless overridden. |
1 private and internal property
| Member | What it is |
|---|---|
private ITarget Alta.Intelligence.ITargetPointer.Target { get; } | Returns this target itself. |
Methods
| Member | What it is |
|---|---|
virtual IEnumerable<AttackParameters> Attacks() (iterator) | The attacks this target can make. Empty in the base class; subclasses override it. |
float GetDistance(ITarget other, float yFlexibility = 0) | Distance between ground positions, ignoring up to yFlexibility of height difference. |
float GetSquareDistance(ITarget other, float yFlexibility = 0) | Squared distance between ground positions, with height difference reduced by yFlexibility (never below zero). |
virtual float GetVelocity() | The target's speed. Always 0 in the base class; subclasses override it. |
override void Initialize() | Hooks the health object's death. Server: sets up senses and registers with TargetCollectorManager. Client: disables the component. |
protected virtual void Killed(HealthObject healthobject) | Called when the health object is destroyed; sets IsAlive to false. Override to add death handling. |
protected virtual void OnValidate() | Editor: fixes up the initial sense setups. |
1 private and internal method
| Member | What it is |
|---|---|
private void OnDestroy() | Server: removes the target from TargetCollectorManager. |
Used in
Members of other types that take, return or hold a Target: