How can i make crosshair disapper when rightclick is released

I m trying to draw a crosshair when rightclick is pressed and erase it when the button is released,I m trying to stay in c++

How are you drawing it currently. Set a bool to not draw crosshair, then in your crosshair draw function call, check to see if that bool is set.

Is the draw function called every frame or,should I use the tick function.one more thing,I have created a bool in character.CPP how can I access that variable in HUD.CPP.

You have to include the hud.h in your character.cpp (or .h). Then you can get from your hudclass the variable.

You can bind the visibility of the crosshair to a UPROPERTY. If you are using Slate i would recommend you to check out how they do it on ShooterGame. Usually you would make your UPROPERTY private and create a public getter UFUNCTION to access it (encapsulation), also, use the meta “BlueprintPure” in order to access that function comfortably from Blueprints (it would make a pure BP accesible function and you will be able to access it on C++ aswell).If you are using UMG, check out this guide about variable (property) binding:

If you have any other further question please do ask it.