Announcement

Collapse
No announcement yet.

How to properly attach a camera component to a socket in a character mesh?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to properly attach a camera component to a socket in a character mesh?

    I use in the constructor:

    Code:
    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:

    Code:
    FPSCamera->AttachToComponent(GetMesh(), FAttachmentTransformRules(EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, true), "FPVCamera");
    Last edited by Tomza; 11-20-2017, 06:09 AM.

    #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?

    Comment


      #3
      I use:

      Code:
      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.

      Comment


        #4
        Did you find a way to get this to work ?

        Comment

        Working...
        X