Cowboy Defense Force

Project Description

Cowboy Defense Force is a multiplayer FPS built in Unreal Engine 5. It was created by a team of five programmers for the 2023 Epic MegaJam with the theme of "antiquated future". The game was designed to play similarly to Call of Duty's Zombies gamemode, with the twist of taking place in a cyberpunk + western fusion setting. The player takes on the role of a cowboy defending their land from robots sent to seize it. They can equip themselves with up to four revolvers of various kinds, which automatically reload when stored in their mechanical holsters. Dealing damage and farming crops earns the player cash which can be used to purchase new weapons.

Accomplishments

  • Trained teammates in UE5 replication and RPCs.
  • Assisted with programming ally revival and other network tasks.
  • Programmed a grenade launcher weapon with radial damage.
  • Implemented a simple farming system that allowed players to plant crops which would grow over time.
  • Developed an interface for interactible objects.
  • Created UI to display player health, player funds, revive progress, and aiming crosshair.

Objectives and Implementation

My goal for this project was to become more adept at using Unreal Engine's network replication features to build online games. I was also interested in working with FPS gameplay, as it was a genre that I had yet to develop for. Our team had one week to complete this project, which for us meant the weekend and evenings during the week.

The biggest challenge that I faced during this project was training the rest of the team to consider what they need to do to get their systems working in multiplayer. On the first day of work on the project, I began by taking time to explain Unreal replication and RPCs to the group members that were able to be present. This proved to be very helpful; though they didn't totally understand how everything worked, the quick crash course was enough to enable the team to get started with prepping things for multiplayer. With each problem that we worked through during development, their understanding grew, and I believe that if we were to work on another multiplayer game in the future, we would be able to burn through tasks much quicker.

One of my favorite parts of working on this project was building the farming system. Our level designer came up with the idea, and I took it upon myself to get it implemented because I believed it fit well with our game's theming and helped to differentiate the concept more from its inspiration. For our farming system, I made a crop spot object where crops can be grown. When the player interacts with them, they plant a seed which automatically grows. The crop object has three stages of growth, with the last two having two possible meshes that could display. Rather than use hard references for each of the possible meshes, I opted for soft references that could be loaded asynchronously when needed.

When the crop reaches its final stage, it acquires a tag which permits players to interact with the object, harvesting the crop and adding to the player's cash. I created the interact event as part of a Blueprint Interface, which allows for easy and quick implementation of new interactible objects.

My work on this project also involved a fair amount of C++ coding, such as with the Grenade object I created. For the grenade's movement, I was able to use Unreal's built-in Projectile Movement Component to quickly establish the speed and bounciness of the explosives. For the actual exploding of the thing though, I had to take matters into my own hands. The code above shows how the grenade calculates damage. The final value is scaled based on distance from the hit actor, thus making it so that actors on the edge of the explosion are less affected compared to those caught in the center of the blast.

Reflection

In the end, I feel happy with what I was able to accomplish for this project. I was able to make an impact on a wide variety of features: I built the player HUD, implemented the revive mechanic, worked with the weapon system, and created the farming system, all on top of being the head networking programmer. During this project, one important thing that I learned was how to add sockets to skeletal mesh objects. While the other weapons in our game used hitscan, the grenades I created were tangible projectiles. This meant that I had to find some way to make it look like they were naturally shooting from the player's gun, and I was able to do that by adding custom sockets to the player's mesh. I haven't done much work with fitting different visual elements together in UE, and I think the knowledge of how to use this feature will come in handy if I need to work with meshes more in the future.

Also, thanks to the MegaJam site, my team and I were able to become more familiar with all of the resources available to developers working in UE. Quixel especially proved to be a fantastic resource for high quality assets that we will certainly consider when developing any future jams. As an engineer-heavy team, tools like this are essential for creating a quality product.