Hi there. Im trying to attach USceneComponent* HoldingComponent
to UCameraComponent* CamComp
in first-person game:
CamComp = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
CamComp->SetRelativeLocation(FVector(0, 0, 40));
HoldingComponent = CreateDefaultSubobject<USceneComponent>(TEXT("HoldingComponent"));
HoldingComponent-> SetRelativeLocation(CamComp->GetForwardVector() + FVector(130.0f, 0.0f, 0.0f));
CamComp->SetupAttachment(GetCapsuleComponent());
HoldingComponent->SetupAttachment(CamComp);
When I move my camera in game, while holding some object, horizontally it moves with camera, but vertically it doesn’t. Any thoughts about it?