Hey guys.
I’m trying to set up a basic weapon class that has a mesh with detailed collision for when it’s lying around on the ground, a separate mesh for the skeleton (PHAT won’t let me use custom collision), and a capsule collision for raytracing so that you don’t need to look directly at the mesh - just nearby.
The code I have for this is as follows:
ACBaseGear::ACBaseGear()
{
RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
RootComponent->SetRelativeLocation(FVector(0, 0, 0));
ViewCollision = CreateDefaultSubobject<UCapsuleComponent>(TEXT("View Collision"));
ViewCollision->AddRelativeRotation(FRotator(0.0f, 0.0f, 90.0f));
GroundMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Ground Mesh"));
GroundMesh->AttachTo(RootComponent);
SkeletalMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Skeletal Mesh"));
HeldMesh->SetVisibility(false, true);
However, dragging out a blueprint-derived class into the game world behaves adversely.
The transform of the BP will be wherever I set it to be - however, the components listed above initialize after I’ve released the mouse, and end up all being located at the absolute world origin. The picture above illustrates this.
I imagine my entire workflow/process for setting this up is flawed, but I can’t find any examples of how to do it right. Any advice?