So this is my code (it extends AActor).
I’m not sure it has anything to do with the collision channel because I got rid of the collision component entirely and still had the same issue where the character just doesn’t move properly and the camera also seems to be affected.
I do wonder whether attaching an Actor to a socket should be done from within the Character class and not from within the Actor class itself (ie ‘this’).
I’m pretty sure I haven’t done anything problematic with the socket either.
And I think i’m accessing the character, its mesh and the socket properly.
So if anyone sees anything obvious, yeah that’d be great.
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;
deviceBody = CreateDefaultSubobject<UStaticMeshComponent>("devicebody");
// when the device is clicked it enters the socket.
deviceCollComponent = CreateDefaultSubobject<USphereComponent>("Collision Component");
RootComponent = deviceCollComponent;
// Called when the game starts or when spawned
ASamuraiCharacter* CharacterReference = Cast<ASamuraiCharacter>(GetWorld()->GetFirstPlayerController()->GetCharacter());
USkeletalMeshComponent* CharacterMesh = CharacterReference->GetMesh();
TArray<FName> sockets = CharacterReference->GetMesh()->GetAllSocketNames();
if(sockets == TEXT("Right_Hand_Object_Socket"))
UE_LOG(LogTemp, Warning, TEXT("socket"));
AttachToComponent(CharacterMesh, FAttachmentTransformRules::SnapToTargetIncludingScale, TEXT("Right_Hand_Object_Socket"));