Hi,
I’m attempting to create a simple press 1 - 4 to change weapon system. I’m working from the C++ first person template. I have created a method that is called whenever the player presses 1. I don’t know how to proceed to write the method.
I want the ammunition in the current magazine to be kept the same whenever the player switches to different weapons.
I have read that destroying the current mesh and then making a new one with a different weapon is possible, also hiding different weapon meshes and only showing one at a time. How would I go about doing this?
This is the template code in the character class that has to do with the weapon:
// Create a gun mesh component
FP_Gun = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("FP_Gun"));
FP_Gun->SetOnlyOwnerSee(true); // only the owning player will see this mesh
FP_Gun->bCastDynamicShadow = false;
FP_Gun->CastShadow = false;
// FP_Gun->SetupAttachment(Mesh1P, TEXT("GripPoint"));
FP_Gun->SetupAttachment(RootComponent);
FP_MuzzleLocation = CreateDefaultSubobject<USceneComponent>(TEXT("MuzzleLocation"));
FP_MuzzleLocation->SetupAttachment(FP_Gun);
FP_MuzzleLocation->SetRelativeLocation(FVector(0.2f, 48.4f, -10.6f));
And then in the begin play method:
FP_Gun->AttachToComponent(Mesh1P, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true), TEXT("GripPoint"));