top of page

Unreal Engine 5.2

Data structure example

The goal here is to demonstrate how I would create a data structure and implement it in Unreal Engine 5.2

Context :

  • I want to create an FPS game with realistic weapon 3C.

  • How do I implement the weapons specifications into my game ?

Here is a short video of the Rate of Fire & Muzzle Velocity being implemented in the First Person shooter project.
The weapon specs are displayed on the top left corner of the video, I recommand watching it fullscreen.

Setting up the structure

First, I create a simple excel with the values I want to handle ingame

dataexcel.jpg

Then I create a Structure in Unreal, and Import my .csv file to create a DataTable

datastructure_unreal.jpg
datatable_unreal.jpg

Using the project template First Person Shooter of Unreal Engine, we can consider the following implementation for our DataStruct.

Our structure can be referenced in the BP_Weapon_Component which is then added to the BP_Pickup_Rifle

datauml.jpg
Implement the structure

Now that our structure is set up, let's implement it to influence the rate of fire and muzzle velocity.
Rate of fire : Controls the speed at which the projectiles are fired
Muzzle velocity : Controls the speed at which the projectile are pushed out of the barrel

Lets initialize some local variable using the Event OnBeginPlay

Such as :
- WeaponSpecs <DataTable> to have a local copy of the table
- CurrentRowName <string> to know which data row we are dealing with at any time
- CurrentRowIndex <int>
to know which data row index of the table we currently handle

data_unreal_bp_01.jpg

To handle the Rate of Fire, delay every call of the "Shoot" input action by the RPM.
(actual rate of fire = 1/(RPM/60))

data_unreal_bp_05.jpg

To handle the Muzzle Velocity, add the Muzzle velocity to the projectile.
Actual muzzle velocity is slowed down for visualization purposes.

data_unreal_bp_04.jpg

© 2016 by Alexandre Cliquennois. Created with Wix.com

    bottom of page