Cards & Castles VR
Award Winning Unity Project
January 2023 - May 2023
Overview
Cards & Castles is a Multiplayer VR Real-Time-Strategy game where players use card decks to summon magical creatures and spells to attack and defend against mythical enemy forces.
​
At the beginning of the Spring 2023 semester, I along with a team of 3 other members began construction of the game from scratch using Unity. I worked closely with the other team members in an agile development environment to produce a working, fun game.
​
By the end of the semester, we were able to present a working game with 4 unique levels, a linear progression system, swappable card decks, and a small multiplayer hub world. Out of the 15 other games during the semester, our game was given the Best Technical Game award by Professor Johnathan Mell.
​
In the future, I will continue working on the game to integrate more features and updates to Cards & Castles. Future work will include a grid-based building system, new character AI functionality, and the design of a Domination/CTF level.
​
​
​
​
​
Timestamp: 3:06-4:43
Best Technical Award
Professor Mell's Highlight Reel
What I Contributed
Character AI Behaviors
I developed a Finite State Machine (FSM) and utilized Unity's NavMesh system and Prefab Variants to code character AI behaviors including:
-
Patrol: Units will patrol a given area using predefined waypoints
-
Pursue: Units will target and chase down the closest enemy that they can detect
-
Attack: Units will attack their target once in range.
-
"Move and Mow Down": Enemy units will travel a path to a given objective and attack anything that stands in their way
Detection System
I integrated a detection system so that AI units would not pursue and attack enemies that they shouldn't be able to see.
-
If a target was in range of an AI unit, it would cast a LineCast between the two's transforms to determine if there was any terrain (wall, ground, etc.) that would obstruct their view of each other.
-
Used to solve the case where ranged units would begin firing projectiles at an enemy but would instead be hitting the wall.
Enemy Spawning Systems
I implemented a spawning system so that enemy AI units would be able to spawn based on the current state of the game.
-
Developed a timer-based spawn system where enemies would spawn from their huts after a given cooldown period.
-
Implemented a spawn system where enemies will "build their forces" by spawning huts on captured objectives.
-
Used scriptable objects to design a wave-based spawning system that spawns predefined waves of enemies at random locations and at a set time interval.
Encountered Problems and Solutions
Detection System
System Overview: During the early stages of development, we used a method for checking for targets within a unit's detection range. This method would collect all units within a given radius and under the Character layer, and filter for other units on the enemy team. This method would return the first enemy in the list that fits those criteria.
Problem: This approach wasn't realistic in that units would be able to target enemies that were behind walls. This was especially problematic because ranged units would start firing projectiles at an enemy behind a wall. Also, the previous version of the method would pick the first enemy out of a list of other units, not necessarily the closest enemy.
Solution: I integrated a detection system to help make AI behaviors more realistic. Within the check method, I put in a LineCast between the unit and its possible target's transform to detect whether anything on the terrain is obstructing their line of view. If there was some obstruction between the two, the method would move on to the next unit it found. It would iterate over all of the units captured in the detection sphere, keeping track of the closest one that is not obstructed from view. At the end, if there was a target that met all the criteria, it would be targeted by the unit.
What I Learned: The easiest solution is not always the most realistic/immersive one. Simple additions such as this create a more immersive experience, even if a player may never consciously notice it.
Move and Mow Down State
System Overview: For the Beasts of the Black Forest and Desert of the Damned levels, we needed enemy AI to pursue and attack the player's Castle Keep, while attacking any of the player's forces it comes across. So I developed a "Move and Mow Down" state where enemy units would move towards their objective and mow down any adversaries in their path. The early version of this state only had the objective as its destination.
Problem: The early version of this state worked when the distance to the objective was small. However, with our large scale maps, we quickly noticed that the AI would jitter when trying to go to an objective on the other side of the map.
Solution: Using Unity's profiler tool, I realized the problem was the limitations of Unity's NavMesh system. When first spawning in the units, we would set their destination to the objective on the other side of our extensive maps, which was heavy on the NavMesh's pathfinding system. I solved this problem by modifying Move and Mow Down to travel a set of predefined checkpoints similar to the Patrol state, with the end point being the objective. This decreased the cost on the NavMesh's pathfinding system, as it would only need to calculate the path to the next checkpoint.
What I Learned: This taught me the importance of not over-relying on built in systems to work as expected in every case. I should look to optimize code and reduce the calculations performed as much as possible at every step.
