I want to allow the player to equip multiple types of tools within my game.
In the character.h I have a tool, which is a blueprint extended class, and i’ve selected that class in the editor
UPROPERTY(EditAnywhere)
TSubclassOf<ATool> Tool;
In my constructor, this line makes my game crash:
// Create a gun mesh component
FP_Gun = Cast<ATool>(Tool)->GetMesh();
And GetMesh() is a function that returns a USkeletalMesh from my Tool class, here is the class:
FORCEINLINE USkeletalMeshComponent* GetMesh() const { return WieldableMesh; }
private:
UPROPERTY(EditDefaultsOnly)
USkeletalMeshComponent* WieldableMesh;
Does anyone know why attempting to call GetMesh crashes my game? Am I approaching this problem incorrectly?