Step 1: Since we have an AimingComponent reference in the UI blueprint already storing the secondary crosshair location there works well. So add this to TankAimingComponent.h
public:
UPROPERTY(BlueprintReadOnly)
FVector2D SecondaryCrosshairLocation;
Step 2: The screen/world stuff is done in TankPlayerController.cpp so wherever you have the DeprojectScreenPositionToWorld (or maybe you went for the alternative GetHitResultAtScreenPosition) you can add this.
barrel = however you reference your barrel in tankplayercontroller and socket names should be yours
FVector firingLocation = barrel->GetSocketLocation("FiringLocation");
FVector endLocation = firingLocation + (barrel->GetForwardVector() * 5000.f);
******
The above line is where the world position is determined. This endLocation (straight ahead of the barrel in this case) can be replaced by line tracing or calculating the projectile path.
******
FVector2D ScreenLocation;
ProjectWorldLocationToScreen(endLocation, ScreenLocation);
int32 viewSizeX, viewSizeY;
GetViewportSize(viewSizeX, viewSizeY);
float adjustedX = ScreenLocation.X / viewSizeX;
float adjustedY = ScreenLocation.Y/ viewSizeY;
*******
Since we are going to be using anchor points which are a percentage of the UI Canvas the bug of UMG thinking all canvases are 1920x1080 is no longer relevant. The screen location is divided by the screen size which gives the necessary floats in a value from 0 to 1 which is how the UI widget anchor points are implemented.
*******
FVector2D adjustedScreenLocation = FVector2D(adjustedX, adjustedY);
AimingComponent->SecondaryCrosshairLocation = adjustedScreenLocation;
The changing of the crosshairs as I have done goes a bit deeper in to referencing separate Enums. I will show the blueprint setup in a bit.