Hi, I just wanna write this code but i didn’t find “Get Mouse X” cpp code. How can i convert this bp to c++
Hi! You can check this
- Get ULocalPlayer with auto localPlayer = controller->Player from APlayerController
- Get UGameViewportClient with auto viewport = localPlayer->ViewportClient
- Check method viewport->GetMousePosition(outPosition)
To call c++ function in blueprint, make sure to add UFUNCTION(BlueprintCallable) on top of function implementation in header file.
By the way UGameViewportClient class also has this
virtual int32 GetMouseX() const = 0;
virtual int32 GetMouseY() const = 0;