top of page

UE4 Blueprint Samples

The following is commented samples from my personal project, Into the Dreadnaught, made entirely in Blueprints in Unreal Engine 4. My examples are from my damage calculator, hitscan code, and my perk request system start-to-finish.

This is my hitscan code, which checks what camera is in use based on ADS or hip fire, and calculates where the shot needs to go. To make sure its possible to do cool trace effects, I make sure that the hitscan starts from the barrel and calculates to where the camera is looking at center.

From there, if the hitscan returns a hit on an actor it gives the data back so we can calculate damage and if the hit was a precision hit before sending off any applicable damage.

This is my damage calculator, which is called whenever a hitscan collides with a target. It takes the current damage of the gun, applies any bonus damage, and then picks a range range based on pre-determined damage variance. From there, it checks if the hit was a precision hit, and returns the damage value back to the hitscan code.

This is my perk system. Every gun has three lists of valid perks, one for each classification of perk archetype. These are damage perks, defensive perks, and utility perks. Every gun has a variable that states how many of each perk type it has, and then on construction it runs this script to select valid perks at random. Here is the start of the system, where it runs through the three perk classifications to request its perks from the lists.

From here it takes selects a random perk from the list, marks it as enabled and then moves it to the top of the end of the array so it won't be selected again.

After that, it sends off the request to the perk manager that exists on the player with the name of the perk, what type of perk it is, and the gun that wants the perk.

The perk manager then takes in that data, goes to the appropriate struct which contains all of the games perks based on their classification, and searches for it by the given name tag.

After locating the perk, it will then add it to the gun and break out of the loop.

bottom of page