There isn’t much information here to go on, but here’s one way to do it:
- Create sockets on the weapon that you are using
- Add those sockets to an array that you can cycle through to select them
- If you are viewing your gun and if a socket is selected, show a widget and set its position based on the position of the socket
You could convert the world space coordinates to screen space coordinates like this:
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0);
FVector2D ScreenPosition;
PlayerController->ProjectWorldLocationToScreen(SocketLocation, ScreenPosition);
Widget->SetPositionInViewport(ScreenPosition);
You could use a less generalized approach if you are certain that your gun isn’t going to really move and will always be in the same position when you are viewing it. You might be able to get away with a widget that takes up the entire screen and just hides pieces of it based on context. This way you don’t need to calculate positioning, but you would have to make a different widget for each gun.
Thanks man really helps