I am trying to add an instance of my weapon class to the player character .cpp file, so that from there I can call the functions from the weapon class (shoot/reload etc.), however this crashes the editor and only opens up again once I remove the code and recompile.
Here is how I attempted to add the weapon actor in the player class:
In the .h:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Weapon", meta = (AllowPrivateAccess = "true"))
class ABaseWeapon* Weapon;
In the .cpp:
Weapon = CreateDefaultSubobject<ABaseWeapon>(TEXT("Weapon"));
Weapon->AttachRootComponentTo(RootComponent);
The error that shows up in the crash report:
Unknown exception - code 00000001 (first/second chance not available)
"Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.10\Engine\Source\Runtime\CoreUObject\Private\Templates\Casts.cpp] [Line: 11]
Cast of MyPaperCharacte
Is this the correct way to add an actor to a player character?