Games Development - Task 3 : Game Prototype
21/04/2025 - ( Week 1 - Week 4 )
Ho Winnie / 0364866
Games Development / Bachelor's of Design Honors In Creative Media
Task 3 : Game Prototype
1. Task 3 - Game Prototype
| Fig 1.1 Enemy Spritesheets |
In this part of the script, I programmed the attack behavior for the Skeletal Monster.
On the right side, the script defines key enemy settings:
-
The
attackTypeis set to Melee — so the Skeletal Monster will only use melee attacks. -
moveSpeedandpatrolDistancecontrol how fast the monster moves and how far it patrols. -
maxHPsets its maximum health points. -
soulDropPrefabis the object it will drop when defeated. -
The
faceRightByDefaultandstopWhileAttackingbooleans help control its orientation and whether it stops moving while attacking. -
Under Attack Logic, it has an
attackCooldownto prevent constant attacks and arangedAttackRange(which won’t be used here since it’s melee only). -
Under Melee Settings,
meleePointis the point in front of the monster where damage is checked,meleeRangedefines how far its attack reaches,meleeDamageis the amount of damage it deals per hit, andtargetLayerdefines which objects it can hit (like the player or minions).
On the left side, the DealDamage() method handles what happens when the Skeletal Monster attacks:
-
It first checks if the enemy’s
attackTypeallows melee — if not, the method stops. -
It checks whether the
meleePointis assigned; if not, it logs a warning. -
The
Physics2D.OverlapCircleAllchecks for any valid targets within themeleeRangearound themeleePoint. -
If a target is found, it loops through each one:
-
If the target is the Player (
PlayerSahiraController), it deals melee damage. -
If the target is a Minion (
MinionFollowerController), it deals melee damage.
-
-
If no valid target was hit, it logs that the attack missed.
![]() |
| Fig 1.2 Skeletal Monster Attack Scripts |
In this part of the Skeletal Monster’s setup, I used an Animator panel to precisely synchronize when the enemy deals damage and when its attack ends. The code checks if the Skeletal Monster is within melee range and if its attack cooldown has passed. If these conditions are met, it resets the attack timer and calls StartAttack(), which triggers the attack animation. The Rigidbody’s velocity is also set to zero on the X-axis so the enemy stops moving while attacking.
In the Animator timeline, I added animation events — “DealDamage” and “EndAttack” — at specific frames. The DealDamage event is timed to match the exact frame when the monster’s attack should hit the player or minion, ensuring that the visual swing and the actual damage line up. The EndAttack event signals when the attack animation finishes, allowing the monster to return to its idle or movement state smoothly. This setup makes the Skeletal Monster’s attacks feel responsive and realistic, tightly linking the animation with the gameplay logic.
![]() |
| Fig 1.3 Skeletal Monster Animator Panel |
Attack Movement of Sand Fox :
For the Sand Fox, I designed a ranged attack system using a projectile script. The right side of the image shows the EnemyProjectile class, which defines the behavior of the fox’s projectile. This script sets key properties like the projectile’s speed, damage, and lifetime. It also holds a reference for a hiteffect that plays when the projectile hits something. The projectile knows which targets it can damage through the playerTag and minionTag variables, so it can hit both the player and minions. When the projectile is spawned, it gets its Rigidbody2D component for movement and is set to destroy itself automatically after a certain time to prevent clutter in the scene.
On the left side, the OnTriggerEnter2D method controls what happens when the projectile collides with something. If the projectile hits the player, it finds the player’s PlayerSahiraController and applies damage. If it hits a minion, it finds the MinionFollowerController and damages the minion too. In both cases, a visual hiteffect can be spawned for feedback, and the projectile destroys itself afterward. The same happens if the projectile hits the ground or a wall, ensuring that it doesn’t linger or pass through obstacles.
Shoot() method to handle how the fox spawns and fires its projectiles. The method first checks that the FirePoint (where the projectile spawns) and the projectile prefab exist, and that the fox currently has a valid target. When the fox shoots, the script instantiates the projectile prefab at the FirePoint position. It also determines the direction the fox is facing to set the projectile’s travel direction correctly. A Rigidbody2D on the projectile moves it forward, and its local scale is flipped if needed so the visual matches the direction. After firing, the EndAttack() method ensures the fox finishes the attack smoothly.StartAttack() — this triggers the projectile animation. In the Animator panel, an event called “Shoot” is placed at the right frame so that the projectile is instantiated exactly when the animation shows the fox attacking.SoundwaveProjectiles. Other general settings, like movement speed, patrol distance, health points, and the soul drop prefab, help make the Sand Fox behave as a ranged enemy that fires soundwave projectiles accurately at the player or minions.| Fig 1.5 Sand Fox Projectile Scripts |
EnemyProjectile script attached to the prefab defines its behavior: the projectile travels at a speed of 5 units, deals 1 point of damage on impact, and has a lifetime of 3 seconds before destroying itself automatically if it doesn’t hit anything. The Target Tags fields specify that this projectile can detect and damage both the player (tagged Player) and minions (tagged Minion).Hit Effect is set, it simply disappears when it collides or when its lifetime runs out. This setup makes the Undead Cat’s long-range attack reliable and ensures it can threaten the player from a distance, adding variety to enemy behavior in the game.| Fig 1.6 Undead Cat Projectile Set Up |
HitEffect that plays on impact. It also stores the tags for valid targets — the player and minions. In the Start() method, the script sets up the projectile’s Rigidbody2D for movement and schedules the projectile to destroy itself automatically after its lifetime expires to avoid clutter in the scene.ShootTowardsTarget method is responsible for aiming the projectile at its target. It calculates the direction vector from the projectile to the target’s position, normalizes it, and then sets the Rigidbody2D’s velocity to move the projectile forward in that direction at the given speed. The projectile’s rotation is adjusted so it visually faces the direction it’s traveling.OnTriggerEnter2D method checks what it hit. If it hits the player, it calls the player’s TakeDamage method and spawns the hit effect before destroying itself. The same logic applies if it hits a minion. If it hits the ground or a wall, it plays the hit effect and destroys itself as well. The SpawnHitEffect helper method handles spawning the impact effect at the collision point to provide visual feedback when the projectile hits a target or the environment.| Fig 1.7 Undead Cat Attack Script |
2. Feedback
3. Reflection




Comments
Post a Comment