
Time: Oct 2023 - Dec 2023
Role: programmer in a team of 5 developers
-
Game Mechanics
-
Enemy AI
-
VFX
Skills: Unity Editor, Unity C#, Unity Particle System, Unity Android Development
Key Features
-
Top-down puzzle solving shooter
-
Environment interaction
-
Pathfinding enemies
-
Twin-trigger control scheme
-
Sokoban, ricochet, dodge and shooting
Unity
Puzzle
Shooter
Responsibility
Enemy logic
The enemy has a detection range, shoot range and a stopping range.
Enemy will patrol in a particular direction forward and back in a certain distance when it cannot see the player. The enemy also does one ray cast to player each frame, and rays can be blocked by walls, doors, or boxes. The max length of the enemy’s ray is the detection range.
If the enemy’s ray cast impacts the player, the player is detected by the enemy, and the enemy will find an eligible path by breadth-first search to chase the player. The enemy will slowly rotate towards the player at a certain rotation speed. If the player is in the enemy’s shoot range, it will shoot straight by its orientation degrees. If the enemy loses track (ray cast cannot hit player) of the player, it will stop and stay stationary.
If the distance between the enemy and the player is lower than stop range, the enemy will stop and just shoot the player while they are in range.
Turrets will shoot constantly toward one direction. Turrets cannot be damaged by normal bullets. They can only be damaged by ricochet bullets.
Super Turrets are much stronger than normal turrets. They will rotate to the player while shooting.

Code of Enemy State Machine
Bullet Ricochet and Damage Logic
If (player) bullet collides with an object, depending on the object type, it will have different results. For hitting the enemy, the bullet will be destroyed, and the enemy take damage. For hitting the wall, the bullet will just be destroyed. For hitting the box, if the box is ricochet one the bullet will reflect, or the bullet will be destroyed, and the box will be pushed a little. For colliding with a switch, normal switch will be activated, and ricochet bullet switch can only be activated by ricochet bullet.

Code of Bullet Richchet
Switch Trigger Logic
The screenshot below shows the script of pressure plate which will be activated when player or box is on it. Activation of a switch results in a specific door opening, and for pressure plate, when the pressure disappears it will be deactivated, and the door will close.
To fix the door displacement problem I also add a small corrective system to make the door closed in correct position.

Code of Triggers
Particles
I created unity particle systems for player bullet ricochet electricity effect, enemy (and turret) death effect, health pickup effect, destructible wall effect and enemy spawn effect.

Particle System of Player Bullet