Getting a Pickup to enable Raycasting in Third Person C++

Hi, a Beginner Programmer asking a question that might have been already asked before(sorry if it has)

I’m trying to create a pickup Actor which would disappear upon collision with the player character and enables the raycasting ability of the player character. I’m trying to get this done by having a boolean variable to act as a trigger in the .cpp file of the ThirdPersonCharacter which will turn from false to true when the character overlaps with the pickup. This is what I have so far:

Pickup.h:



public:
// To Access Character from the Pickup

    AProjectPlatformerCharacter* PlayerController;

    void GetPlayer(AActor* MainCharacter);


UFUNCTION()
        void onPlayerOverlapPickupBox(UPrimitiveComponent*overlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);


Pickup.cpp:



// Function to change boolean value and enable raycasting
void ADynamicPickup::GetPlayer(AActor* Player)
{
    PlayerController = Cast<AProjectPlatformerCharacter>(Player);

   PlayerController->bCanRaycast = true;

}

ThirdPersonCharacter.h:



public:
// Trigger for Activation of Raycasting Powers

    bool bCanRaycast;


private:

    void Raycasting();


ThirdPersonCharacter.cpp



//Set up Left Mouse Button to Raycasting Function
    if (bCanRaycast == true)
    {
        PlayerInputComponent->BindAction("Fire", IE_Pressed, this, &AProjectPlatformerCharacter::Raycasting);
    }



I already have the function for raycasting and it’s working normally as I’m using DrawDebugLine and it appears correctly. However, I’m not sure if the code in RED is correctly written or not. Can anyone help me?

tl;dr: How do I change a boolean value that’s in the character.cpp to enable the raycasting from the pickup? or is there another approach that I should be doing?