How to properly use a custom weapon in FPS C++ template ?

Hey there ! Thanks in advance for helping with my issue !

So here’s my situation. I’m working on a project based on the C++ FPS Template, and I wanted to replace the base weapon model by an AWP model ( The rifle model ) and reposition it so the gun is hold in front of the camera.
What I did was to go in the “FirstPersonCharacter” Blueprint Class generated with the C++ code, find the inherited component FP_Gun, and replace the SK_FPGun skeletal mesh with the skeletal mesh I imported from the AWP model.
I then tried to reposition and redimension the arms and the rifle, but I couldn’t manage to get it to work.
I tried it several ways : repositionning in the blueprint itself, changing the values in the SetRelativeLocation and SetRelativeRotation in the C++ code, but none of them worked. Especially, regarding the C++ code change, I don’t know if I did it correctly but the C++ lines didn’t seem to have an impact, I could change the values or even comment these lines, but no effect would be seen after compiling.

If it helps, here’s my code, and some screenshots to illustrate my problem :

The Character blueprint :

The Character while playing (the gun position/dimension actually matches the gun basic position before repositionning) :
image

The code I tried to edit :

ASFSProjectCharacter::ASFSProjectCharacter()
{
// Allow ticking
PrimaryActorTick.bCanEverTick = true;

// Set size for collision capsule
GetCapsuleComponent()->InitCapsuleSize(55.f, 96.0f);

// set our turn rates for input
BaseTurnRate = 45.f;
BaseLookUpRate = 45.f;

// Create a CameraComponent
FirstPersonCameraComponent = CreateDefaultSubobject(TEXT(“FirstPersonCamera”));
FirstPersonCameraComponent->SetupAttachment(GetCapsuleComponent());
FirstPersonCameraComponent->SetRelativeLocation(FVector(-40.0f, 0.0f, 64.f)); // Position the camera
FirstPersonCameraComponent->SetRelativeRotation(FRotator(0.0f, 0.0f, 0.0f));
FirstPersonCameraComponent->bUsePawnControlRotation = true;

// Create a mesh component that will be used when being viewed from a ‘1st person’ view (when controlling this pawn)
Mesh1P = CreateDefaultSubobject(TEXT(“CharacterMesh1P”));
Mesh1P->SetOnlyOwnerSee(true);
Mesh1P->SetupAttachment(FirstPersonCameraComponent);
Mesh1P->bCastDynamicShadow = false;
Mesh1P->CastShadow = false;
Mesh1P->SetRelativeLocation(FVector(3.5f, -10.0f, -160.0f));
Mesh1P->SetRelativeRotation(FRotator(0.0f, 0.0f, 0.0f));
//Mesh1P->SetRelativeRotation(FRotator(0.9f, -20.4f, 7.1f));

// Create a gun mesh component
FP_Gun = CreateDefaultSubobject(TEXT(“FP_Gun”));
FP_Gun->SetOnlyOwnerSee(false); // otherwise won’t be visible in the multiplayer
FP_Gun->bCastDynamicShadow = false;
FP_Gun->CastShadow = false;
FP_Gun->SetRelativeLocation(FVector(65.0f, 10.0f, 95.0f));
FP_Gun->SetRelativeRotation(FRotator(0.0f, 0.0f, 0.0f));
FP_Gun->SetupAttachment(Mesh1P, TEXT(“GripPoint”));
// FP_Gun->SetupAttachment(Mesh1P);

FP_MuzzleLocation = CreateDefaultSubobject(TEXT(“MuzzleLocation”));
FP_MuzzleLocation->SetupAttachment(FP_Gun);
FP_MuzzleLocation->SetRelativeLocation(FVector(0.2f, 48.4f, -10.6f));

// Default offset from the character location for projectiles to spawn
GunOffset = FVector(100.0f, 0.0f, 10.0f);

// Note: The ProjectileClass and the skeletal mesh/anim blueprints for Mesh1P, FP_Gun, and VR_Gun
// are set in the derived blueprint asset named MyCharacter to avoid direct content references in C++.
}

I tried to give as much details as I could, if anything isn’t clear feel free to ask for more !

Thanks :slight_smile: