Hi everyone !
As a beginner on Unreal Engine, I have many issues with attaching an actor (which is basically a weapon) to the hand of my Character !
Here is where I tried to attach the weapon to the socket
AHumanoide::AHumanoide()
{
FName fnWeaponSocket = TEXT("hand_lSocket");
UWorld* World = GetWorld();
if (World)
{
arc=GetWorld()->SpawnActor<AArmeADistance>(AArmeADistance::StaticClass());
arc->AttachRootComponentTo(GetMesh(), fnWeaponSocket, EAttachLocation::SnapToTarget, true);
}
}
And here is the constructor of my weapon
AArmeADistance::AArmeADistance()
{
RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
//définition du mesh
StaticMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
static ConstructorHelpers::FObjectFinder<UStaticMesh> mesh(TEXT("StaticMesh'/Game/Projet_Dragonnier/Equipement/Armes/ADistance/Arc/Arc.Arc'"));
StaticMeshComponent->SetStaticMesh(mesh.Object);
StaticMeshComponent->SetSimulatePhysics(false);
StaticMeshComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision);
StaticMeshComponent->SetupAttachment(RootComponent);
}
I’ve tried many things but the weapon is still spawning at the origin and never in the hand off my character …
Could someone help me ?
Thanks you a lot !