My Portfolio

Thursday, July 15, 2021

VR Card Battle Game - July 15th

Game Play Trailer - Vertical Slice

This is a overview of the VR Card Battle Game System prototype which was built for Oculus Quest using Unity 2019. This was a project inspired from a friend who is a fan of card games. I thought it'd be pretty cool to make a real-time VR battling card battle game with deck building.

YouTube Video - Game System Overview

The game play loop is very simple and is a cycle of defeating your enemies to get rewards which allow you to build a stronger card deck and beat more enemies. Victory is achieved when the enemies health is reduced to zero. You accomplish this by using magical weapons which spawn from a selection of magical cards. Defeated enemies provide several magical cards which you can incorporate into your deck for the next enemy. 

The Gameplay Loop

In terms of similar games I think of it as a combination of the projectile slashing from Beat Saber mixed with card games like Slay the Spire.

Card System
The cards form the core system of the game and I tried to keep the scope limited so there are only four types of cards.. 

The primary damage card in the game is the basic sword card which fires a projectile when charged up. The second card is a shield that allows you to block projectiles and recharge mana. Third is a spell fireball card which deals larger damage at the cost of mana. Finally is the draw card which provides a small heal and allows you to draw a new card.

Decks are based on a list of Card Scriptable Object which contain the basic information for the card. The deck gets loaded at the beginning of a match for the player. When you draw your hand a generic Card is created which is then passed the Card Scriptable object which will determine the look and effects of the card.
Example Card Scriptable Object
VR Interactions
VR interactions and set up is done using Unity's XR Interaction toolkit which is easily extendable and its how I add my own interactive elements to the game objects such as making the sword fire a lightning range attack when you use the trigger button on the controller.

One of my focus for this project was to implement SOLID design principles as well as to try and avoid creating a massive singleton. This led me to learning more about how to use scriptable objects as a bridge and the power of combining events with scriptable objects which is incredibly useful. 

If your curious about using events and scriptable object together I recommend you check out the Unity's Open Project where they explain how they implemented it.  

Enemy AI
The main challenge was creating an enemy AI that behaves differently based on what cards the player chooses . To challenge myself I decided to try and implement two enemies which use either a finite state machine or a simple behavior tree. 

My finite state machine enemy was based on a tutorial a unity tutorial where they used scriptable objects. I just changed the scripts and behaviors in the scriptable objects to suit my specific purposes. If your interested in the tutorial you can learn more about it here.

The enemy basically checks against a series of decisions whether it needs to change state and those decisions are based on what card the player currently has selected. Each card selection state will lead to attack state where you can plug in what you want to occur. You just add the corresponding attack scriptable object which would be how many projectiles and which spawn location you want it to occur from.

The second enemy uses a behavior tree that relies on scriptable objects which I learned from this tutorial. There are probably really good existing solutions but I wanted to try and program a basic behavior tree for my own personal learning.

The end result isn't visually easy to use but still fairly straight forward for customizing. You have three types of nodes which are the Selector, Sequence and Tasks nodes. It has a default idle behavior which is to look at the player and wait for card selection. When the player has selected a card the behavior tree runs the corresponding attack sequence. 

Both enemies share the same code for projectile management and the behavior tree or state machine just need to provide the attack data.

All in all, I learned a lot from this project and hope you enjoyed this rough overview. The code is available on my github if you want to take a closer look.

No comments:

Post a Comment