I have created a small script:
Constructor of character:
AMainChatacter::AMainChatacter()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
MainCharacterCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FirstPersonCamera"));
check(MainCharacterCamera != nullptr)
MainCharacterCamera->SetupAttachment(CastChecked<USceneComponent, UCapsuleComponent>(GetCapsuleComponent()));
MainCharacterCamera->SetRelativeLocation(FVector(50, 0, 80 + BaseEyeHeight));
MainCharacterCamera->bUsePawnControlRotation = true;
stick = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MagixStick"));
static ConstructorHelpers::FObjectFinder<UStaticMesh>sphereShape(TEXT("'/Game/StarterContent/Shapes/Shape_Cylinder.Shape_Cylinder'"));
if (sphereShape.Succeeded())
{
stick->SetStaticMesh(sphereShape.Object);
}
stick->SetupAttachment(MainCharacterCamera);
}
Header:
public:
UPROPERTY(VisibleAnywhere)
UCameraComponent* MainCharacterCamera;
UPROPERTY(Category = MeshComp ,VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
UStaticMeshComponent* stick;
I am not able to move the UCameraComponent an the UStaticmeshComponent (stick)
some help would be appreciated 