Elemental Arrows
Introduction
In our specialization course I wanted to make something gameplay related, I always wanted to make some kind of project which includes a bow. Also I wanted to try out Unreal Engine because I am quite familiar with Unity and in our education we have been working in our own custom engine quite a lot so I saw this as a perfect opportunity to make a Character Controller with a Bow in Unreal Engine 5.
In our group project “On the Goose” I had just made a Character Controller similar to “Mirror Edge” so I wanted to focus more on the bow mechanics. So I took inspiration from one of my favorite games “Divinity : Original Sin 2” and wanted to make arrows with different elements interact with each other and the environment to create cool interactions.
Goals
-> Get to learn Unreal Engine 5 workflow with C++ code and get familiar with the software
-> Create a First Person Perspective Character Controller with a Bow
-> Create the different type of elemental arrows (Fire, Ice, Oil, Water, Electric)
-> Create a target which can handle the different interactions of the elemental arrows
-> Implement interactive environment which the elemental arrows can interact with
Tips: Press picture for bigger view
Arrow Interactions
Workflow
Engine
Because I had nearly no experience working with Unreal Engine 5, I had no clue on how the workflow worked with C++. The workflow I ended up with was working directly in Visual Studio and launching UE5 (Unreal Engine 5) through it. Whenever I made adjustments in scripts I used the recompile button in UE5. However if I made a change in a header file or constructor for a class, I had to close UE5 and relaunch it through Visual Studio.
Creating C++ Class
Create a C++ class in UE5, then edit the class in Visual Studio. After completing the class I created a blueprint class from the C++ class. The blueprint classes were used as prefabs, I made some variables in the class visible in the blueprint class so I could edit/assign variables which I used a lot during this project.
Flowchart From C++ class to Prefab
Implementation
CharacterController
For my character controller I created it deriving from UE5 Superclass Character, because I wanted to focus more on the bow mechanics I used one of UE5 own components to create the movement on the character.
The Character can look/move around, shoot and jump. Then in the Character blueprint class I adjusted the values to make it fit this project.
Character Blueprint class/C++
Bow
Next up was making the bow, Created it deriving from UE5 Superclass Actor. Started with spawning and attaching the bow to the Character. I bumped into a minor problem. The bow I spawn did not have the assigned variables I gave it. I realized that the bow I spawned was the C++ class variant and not the blueprint one. Added charged bow shoot, depends how long the player holds the shoot button.
Bow Blueprint class/C++
Arrows
After having the experience with making the bow, the arrow class was easy to make. Started of by making it spawn on a specific point. Then to make it move gave it UE5 ProjectileComponent which I later on adjusted the values in the blueprint class.
After it could fly I made an OnHit function which could recognize which Actor it collides with and then writes out a name of the colliding Actor.
I faced a problem that the arrows could collide with each other. Fixed this by using UE5 collision layer system which was kind of similar to the one Unity uses.
Created a header file which holds the enum ElementStatuses, this will be used as an identifier which elemental status the arrows has. Now that the elemental status done we can start on the elemental arrows.
Started with the fire arrow, made a C++ class which derived from the Arrow class. The variables which the elemental arrows had that were different from each other are element Status and status Duration. To make it easier to send the data between classes I created a ArrowData struct. After implementing one of the arrows, it did not take long until all elemental arrows were implemented.
I created a struct in Character class called Quiver which had every elemental arrow. Made every arrow visible in the blueprint class so I could put in the prefabs of the elemental arrows in the struct. Added inputs so I could switch between the elemental arrows using 1-6.
Arrow Header
ElementalStatuses
ArrowData struct
Quiver struct
StatusComponent/Target
The purpose of the status component is to calculate the reaction depending on which elemental arrow it got hit by as well as which it is. Making the status component was a bit different because it was a Component instead of an Actor but it worked out smoothly. Created AddElementStatus function which takes in a element status, and calculates which status it should receive.
Then I adjusted the arrow OnHit function and made it so it can only apply element status on Actors with the status component.
I created a Target class which derived from UE5 Actor class that I attached the status component on. For debugging I created a function which returned a element status as a string. I also added a text above the target which shows what element status it has and a timer which shows how long it will hold.
On Hit function/CalculateHit
Target Blueprint class
Crosshair
I noticed it was very hard to aim because I did not have a crosshair so I made myself which was made up of 3 pictures. I made a dynamic one to match the power of charge when you shoot. This one was quite different from the rest because I made this one with Blueprints instead.
Crosshair Animation
Particles
In the UE5 there is a starter content package which has some cool particles. So I decided to implement these particles depending on which elemental status a Status Component had.. In the starter content there was a Fire and Electric particle, but it was missing a Frozen one so I made a outline shader in UE5 and used it as the Frozen status particle.
Particle Showcase
Summary
Even if I did not reach all of my goals, I was really happy with the resulting arrows and bow. I underestimated how tough it would be to jump into UE5 and my planning paid the price. I really enjoyed this project and thought it was fun to try out a new Engine, I’ve learnt a lot in this project and feel much more confident in UE5. I am a bit saddened about that I did not get any of the environmental interaction stuff implemented, I believe that mechanic would so much fun to work with and that it would give extremely cool interactions.