Skip to main content

EruptAreaAttack

A class in Root.Township, the global namespace.

Networked creature attack that makes an object erupt from the ground near the agent's target. The server picks the spot and syncs it to clients.

Constructors​

MemberWhat it is
EruptAreaAttack()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

15 private and internal fields
MemberWhat it is
private Agent agentAgent whose target is attacked; it must be alive.
private Animator[] animatorsAnimators that get the trigger.
private MethodSync attackMethod sync for the attack.
private AltaCoroutine attackingThe running hide timer.
private float durationSeconds the eruption stays visible.
private Transform eruptingObject that is moved to the spot and shown.
private bool isUsingNormalUpAlign the eruption to the ground normal instead of straight up.
private float offsetFromTargetHow far short of the target the spot is placed.
private float radiusFurthest the spot can be from the attacker.
private float raycastLengthLength of the ground raycast.
private LayerMask raycastMaskLayers the ground raycast hits.
private float raycastStartAboveTargetHeadHeight above the target's position where the ground raycast starts.
private string triggerAnimator trigger name, "Attack" by default.
private Vector3 worldPositionChosen eruption position, also synced.
private Quaternion worldRotationChosen eruption rotation, also synced.

Methods​

MemberWhat it is
void Attack()Server: picks a spot towards the target (or random within radius), raycasts down to the ground, shows the eruption and syncs it.
override void Initialize()Creates the sync, hides the eruption object and reparents it when the entity is destroyed by the scene.
6 private and internal methods
MemberWhat it is
private void AttackLocal()Unparents the eruption object, places it, enables it, fires the animator triggers and starts the hide timer.
private void AttackSync(IPlayer player, Stream stream)Sends the position and rotation; clients play the attack when they read it.
private void OnDisable()Forgets the running timer.
private void OnDrawGizmosSelected()Empty.
private void Rechild(NetworkEntity entity, bool isUnload)Puts the eruption object back under this transform.
private IEnumerator Timer() (iterator)Waits duration, then hides the eruption object and reparents it.