Creating Combat in Unreal Engine 5

link to play — https://aviparmar.itch.io/combat-in-unreal-engine-5

Brief

I attempted to create a version of the popular Atari game ‘Combat’ in Unreal Engine using third-person controller templates to learn UE5 and blueprints.

In this blog post, I will be going into all the different mechanics of the game and the blueprints I made to make everything work.

Combat

Combat is an old Atari game where two players try to shoot each other out within a given timeframe.

I tried to make something similar, while trying to leverage the strengths of Unreal Engine.

This meant using the third person controller given by Unreal, leveraging photorealistic quixel assets, and making enemy AI.

Screenshot from the game

Third Person Controller

Controls

  • The default controls that came with the template were WASD to move, and space to jump
  • I had to add a sprint function, so the user can hold on shift to sprint
Simple blueprint function to allow the user to sprint
  • I also added a projectile function, so when the user clicks on right mouse button, the character shoots a projectile.
Blueprint to shoot
Player UI

Health & Time

  • A UI canvas was created to display the various discrete mechanics such as time and health, and all the code for this was made in the Third Person Character blueprint.
  • Since I was still learning at the time, the blueprint was pretty messy. If I had to do this again, I would wrap it all in a function instead of making it in the event graph itself.
Blueprint for checking win and lose conditions
Blueprint to make a timer

Enemy AI

Pawn sensing component

  • A pawn-sensing component was used to power the enemy AI’s movement.
  • This was connected to the projectile mechanic as well, so that the enemy could shoot
  • The shooting mechanic was given a reload time to adjust the difficulty of the game.
Blueprint for projectile
Blueprint for following the player
Early movement testing
  • Since the game still felt too easy, and the enemies weren’t scary, I had to make a couple of changes
  • The first change was to make the enemy material red, and the player material blue
Enemy Model
Player Model
  • The second change was to make it so that when the enemy is far, they would sprint, and when the enemy was close, they would walk.
  • I could easily recycle code from the third person controller for this, but had to configure a walk and sprint animation
Blueprint to check distance, and sprint if too far
Animation graph that checks speed and blends between walk and sprint animation accordingly
1 dimensional graph to combine the two types of animations

Environment

  • The map of the game was a copy of the old Atari game combat.
Early Screenshot of the map, with AI limited to movement in the first 3 quarters only
Orthographic top view
Combat
  • The assets were from quixel, imported into unreal using the fab plugin.
  • I wanted to experiment with terrain and foliage, so I imported some rocks and grass assets as well
  • The terrain was made with the built in terrain mode on unreal, and foliage was spread with the foliage mode
Foliage and terrain, with various assets from quixel
  • I added in various lighting effects, like exponential height based fog, volumetric clouds, sky light, sky atmosphere and directional light to make the scene look more dynamic.
Screenshot after adding lighting effects
  • Various sound effects were also added to sell the feel of the game

Leave a Reply

Leave a Reply

Discover more from Avi

Subscribe now to keep reading and get access to the full archive.

Continue reading