I’m trying to make a third-person-shooting game. I made Weapon Class having some logic for spawning bullets.
Then I tried to add the weapon in PlayerCharacter class, like this:
// PlayerCharacter.h
UCLASS(config=Game)
APlayerCharacter : public ACharacter {
...
protected:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Player", meta = (AllowProtectedAccess = "true"))
class AWeapon* Weapon;
...
};
// PlayerCharacter.cpp
APlayerCharacter::APlayerCharacter() {
...
Weapon = CreateDefaultSubobject<AWeapon>(TEXT("Weapon"));
Weapon->AttachToComponent(RootComponent, FAttachmentTransformRules::SnapToTargetIncludingScale, FName(TEXT("index_01_r")));
...
}
There is no compile error but the weapon is not added into PlayerCharacter’s blueprint . So, how can I make the PlayerCharacter possess the weapon?