Enemies - Richardng12/Terra_Tales GitHub Wiki

Enemy Design

Enemies in Terra Tales share many common functionality. All enemy prefabs implement ICharacter interface (health, movement, ), all enemies also cause damage upon collision with the player, and all sources of damage from enemies cause one health point of damage. Furthermore, enemies are all implemented as spawnable objects.

Cloud (City Level) Enemy

The first enemy encountered in Terra Tales is the cloud enemy. Cloud enemy can "rain" acid, causing damage with the player upon collision.

Movement for the cloud enemy consists of left and right movement. Direction is changed when the cloud enemy hits a boundary, which is defined by a invisible tilemap.

Fire (Forest Level) Enemy

The fire enemy is encountered in the forest level of Terra Tales. The fire enemy shoots balls of fire towards the player, damaging the player upon collision. The fire balls have travel time before the object destroys itself.

Similar to the cloud enemy, fire enemy movements consists of left and right movement. However, direction is controlled by ray casting. This is because this enemy does not "float", therefore it remains on set platforms. Ray casts are made to the left, right, and downward direction of the fire enemy. If the left or right ray casts hit an obstacle, the fire enemy will change direction. Inversely, if the downward ray cast does not detect an obstacle (no ground beneath), the fire enemy will change direction. Ray casts are also masked to detect only certain layers (ground), so other colliders (e.g. player) will not give a false collision.

Oil (Ocean Level) Enemy

The ocean enemy is encountered in the final level of Terra Tales (Ocean). The oil enemy does not shoot or rain any projectiles, however, the oil enemy will constantly move towards the player. The oil enemy creates a reference to the position of the player object upon instantiation, and will move towards the player based on its calculated Vector2d.

Also, similar to the cloud enemy, the oil enemy utilises an invisible tilemap to detect map boundaries. When the oil enemy hits an invisible boundary, it moves towards the map centre for a set time before resuming following the player.