I have been using the blueprint scripting tools in Unreal to craft a First Person Shooter. This is my first really large scale project, and I have been having issues left and right. I, before was using just the mesh of a weapon and attaching it at Grip Point for testing purposes while I set the necessities up. (See Below the Mesh)
Sci-Fi Machine Gun Static Mesh
My Method of Weapon Actors
Once I got through the basic setup of the mechanics and gameplay, I began to need weapons that carry each their own statistics and characteristics that can still be called to, stored as variables (i.e. Inventory/Equipment), fire its own projectile, and work on its own as to not slow other assets.
I created a parent asset and called it WeaponFirearm (as I do have classes such as Firearm, Lobbed, Melee, etc…) and also created all of the munitions, rate of fire, damage, range, etc… within this same parent. Once done, I created a child of that parent and named this actor L4ZR_80Y in a comic sense as “Lazer Boy”. Within this Lazer Boy Child Actor Blueprint, I select the class defaults, and edit their values directly through the child.
Weapon Firearm Master Class for Guns
Why This Method
This allows me to simply set the Owner variable I had created in the parent blueprint to the Player’s character, then:
[Get Owner]_/-> [Cast to PlayerCharacter] ->[Get Weapon] -> [Get Child Actor] _/->[Cast to WeaponFirearm] -> [Get BaseDamage]/[Get BaseRange]/[Get BaseFirerate]/[Set MagazineCurrent]/[Set MagazineMaximum]
Along with the ease to access information per item, it allows my PlayerCharacter to Cast to the Weapon (in the same manner as the example) and Call Event Dispatchers for things such as Reload_Event, StartShooting_Event, StopShooting_Event, Equipped_Event, and more because these have also been created and stored in the parent actor for the weapon.
L4ZR_80Y in the Content Browser
And so it Begins
After creating this child actor for the first time, the player held the weapon, shot the weapon, reloaded, and completely animated correctly. I began tweaking a couple of variables on the player. Keep in mind, these had nothing to do with the weapon, as not only is it a child actor, but fully functioning within itself and not requiring the player for anything but Attaching the weapon child actor to the player arms mesh. Upon pressing compile after changing the variable (as I do and was doing prior), the editor crashed with a bug report, so I sent and restarted. After trying to simply open any level, asset, or anything else with this child actor within it, the editor would crash. I looked at the bug report (which I will supply)), I saw:
Fatal error: [File:D:\Build\++UE4+Release-4.14+Compile\Sync\Engine\Source\Runtime\CoreUObject\Private\Templates\Casts.cpp] [Line: 11] Cast ofLinkerPlaceholderExportObject/Game/GameObjects/Characters/Playable/PlayerCharacter.PlayerCharacter_C:Weapon_GEN_VARIABLE.Weapon_GEN_VARIABLE_L4ZR_80Y_C_CAT to Actor failed
I decided to attempt to delete the Child Actor Class from within the editor, but again, I got the same issue. I had to navigate to the File Explorer → My Documents → Unreal Projects → Hyperreal → Content → Game Objects → Armory → Firearms → EnergyAutomatic → EnergyAssault. Once there, I expected to see the soul object that I had created there, L4ZR_80Y; instead, I found a lingering file of less than 1KB in size. Deleting this lingering file (always as a .uasset) does nothing to fix the problem, the same crash file and all. Deleting the L4ZR_80Y Child Actor Class, whether the lingering file is deleted or not, the crashing stops. The lingering file is never there until the crashing begins. At one time, the lingering file was named L4ZR_80Y_C_0.uasset, and this current go around is NewBlueprint.uasset. This time, rather than the crash from editing a variable inside of PlayerCharacter, the editor crashed while editing a freshly created variable for the Upgrades Interface.
File Explorer with Lingering Asset
Upgrades Menu - this menu is nested within a widget switcher in the in game action menu
The Worst Part
I have already been forced to restart this project four times, once in 4.13, three in 4.14, and will not do it again. My framerate stays at about 40 even on Epic Quality Settings until bodies begin to pile up. My favorite part of game design is slowly becoming the biggest dread of it with designing and implementing the weapons and objects. Every time that the crash begins, the only way to even open a level with a PlayerStart is to delete the L4ZR_80Y asset from my computer file explorer. I can’t even open the asset in the editor to get the code duplicated before I delete it. I have to start back at square one every time. I would show the blueprint for the weapon including the Shooting, Reloading, Equipping, Etc…, but the editor will not let me access them.
My Desktop Specifications
*Model | Dell XPS 8300 Sleightly Modified x64 Based Architecture
*Operating System | Windows 10
*Graphics Card | AMD Radeon HD 7770 Graphics See More…
Engine Clock | 1000MHz
Memory | 2GB GDDR5 Memory
Image Quality Enhancement | *24x Multi/Super Sampling/Adaptive AA, MLAA, EQAA, 16x Angle Independent
Anisotropic Texture Filtering
*Memory | 2x 8GB
*Hard Drive | 1TB Samsung w/644GB Remaining
*Processor | Intel Core i7-2600 CPU @ 3.40GHz, 3401 Mhz, 4 Cores, 8 Logical Processors