Project
Tower Defense Template
Tower Defense Framework Resource
Tutorial
Intermediate
10 Mins
Unity Technologies
Overview
You have completed 0% of this Tutorial.
1.
Action Game Framework
Summary
This resource provides documentation of the Action Game Framework used in the Tower Defense Template. Find descriptions of many of the methods used in the project.
Language
English
Recommended Unity Versions
2017.2
1.
Action Game Framework

Audio

HealthChangeAudioSource

Health change audio source - a helper for playing sounds on Health Change
 

HealthChangeSound

Health change sound - maps a health change to an AudioClip

HealthChangeSoundSelector

A component that will play a specific AudioClip when a certain amount of damage is received.

RandomAudioSource

A helper for playing random audio clips. The randomness is not uniform but rather based on weights
 

WeightedAudioClip

A WeightedAudioList contains an array of WeightedAudioClips. Individual clips can be given a higher probability of selection

WeightedAudioList

Class used by the RandomAudioSource, from which an AudioClip is chosen

Health

Damageable

Class for handling health using events.
Events available for subscription:
  • Action reachedMaxHealth
  • Action<HealthChangeInfo> damaged
  • Action<HealthChangeInfo> healed
  • Action<HealthChangeInfo> died
To apply damage to the damageable the TakeDamageWithAlignment method must be called. This is primarily done through the DamageableListener.

DamageableBehaviour

Use this component for game objects that need to take damage. It has a Damageable field, Configuration, that handles all damage and fires off events when appropriate. The Configuration’s health and alignment fields can be set on the component or dynamically.
 
The Health Visualizer Prefab, is the HealthVisualizer used to communicate the health of the Configuration to the player. The Health Visualizer Offset is simply the local position of the Health Visualizer Prefab when instantiated.

DamageableListener

The DamageableListener is a component that allows you to easily assign UnityEvents to the DamageableBehaviour’s Damager events.
 

DamageCollider

A component that when collided with a Damager component will apply damage to the corresponding DamageableBehaviour.
 

Damager

A component required to apply damage to a DamageableBehaviour.
 

DamageTrigger

A component that when triggered by a Damager component will apply damage to the corresponding DamageableBehaviour.
 

DamageZone

Abstract class that receives damage and applies it to the damageable behaviour. Inherited by
DamageTrigger and DamageCollider

HealthChangeInfo

A struct that is passed through the Damageable’s health events.

HealthVisualizer

A component used to visualize the health of a Damageable.

HitInfo

A class required by some damage listeners. Stores HealthChangeInfo and Vector3 for the damage point.

Helpers

Ballistics

Static helper class to assist with calculation of common projectile ballistics problems.
List of methods:
  • CalculateLinearFireVector
  • CalculateLinearFlightTime
  • CalculateLinearLeadingTargetPoint
  • CalculateBallisticFireVectorFromAngle
  • CalculateBallisticFireVectorFromVelocity
  • CalculateBallisticFireAngle
  • CalculateBallisticFlightTime
  • CalculateBallisticLeadingTargetPointWithSpeed
  • CalculateBallisticLeadingTargetPointWithAngle

Projectiles

BallisticsProjectile

Simple IProjectile implementation for projectile that flies in a parabolic arc. Can be configured to launch using an angle or speed.
 

HomingLinearProjectile

Basic override of LinearProjectile that allows the projectile to adjust its path in-flight to intercept a designated target. Has configurable leading parameters.
 

IProjectile

Interface allowing specification of generic projectiles
Has the following methods:
  • FireAtPoint(Vector3 startPoint, Vector3 targetPoint)
  • FireInDirection(Vector3 startPoint, Vector3 fireVector)
  • FireAtVelocity(Vector3 startPoint, Vector3 fireVelocity)

LinearProjectile

Simple IProjectile implementation for a projectile that flies in a straight line.
 

WobblingHomingProjectile

A specialized override of HomingLinearProjectile that has three states
  1. Wobbling. The projectile flies in a wobbling, seemingly out-of-control, manner
  2. Turning. The projectile turns towards its designated target
  3. Targeting. Behaves like a regular HomingLinearProjectile and flies to intercept its designated target
 

Spawning

HitObject

Abstract MonoBehaviour. A special type of component that consumes hit info.

HitObjectSpawner

Abstract MonoBehaviour. Provides a public method for spawning game objects based on a hit.

RandomHitObjectSpawner

Implementation of the HitObjectSpawner which chooses a random GameObject from a WeightedObjectList.
 

SingleHitObjectSpawner

Implementation of the HitObjectSpawner that provides one game object to spawn.
 

WeightedObject

Class with a serializable weight and GameObject field. Used by WeightedObjectList.

WeightedObjectList

Class with a serializable WeightedObject[]. Has a method to return a random game object based on weight from the array.