Tomza
(Tomza)
November 20, 2017, 10:07am
1
I use in the constructor:
FPSCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FPSCamera"));
FPSCamera->SetRelativeLocation(FVector(0.0f, -20.0f, 55.0f));
FPSCamera->SetRelativeRotation(FRotator(0.0f, 0.0f, -90.0f));
//FPSCamera->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetNotIncludingScale);
FPSCamera->SetupAttachment(GetMesh());
And in the BeginPlay:
FPSCamera->AttachToComponent(GetMesh(), FAttachmentTransformRules(EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, true), "FPVCamera");
Tomza
(Tomza)
November 20, 2017, 10:09am
2
The camera component should follow the socket of the mesh. I’m unable to do that because the camera doesn’t follow the socket. I cannot parent the camera to the mesh in C++. How to do that?
Tomza
(Tomza)
November 20, 2017, 11:08am
3
I use:
FPSCamera->AttachToComponent(GetMesh(), FAttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, EAttachmentRule::KeepRelative, true), TEXT("FPVCamera"));
It parents the camera to the mesh, but it is not snap to the socket - it is not moving with the socket; it is stiff.
Did you find a way to get this to work ?