How do I return mouse coordinates via C++?

I’ve been trying to get the mouse position via the function GetMousePosition() within the controller class that I created. How can I accomplish this? I’ve been running below code, but the coordinates that I always get are : 0 and 0.

Additionally the GetMousePosition returns true.


void AControllerPlayer_Last::GetPointerLocation()
{
	float LocationX;
	float LocationY;
	GetMousePosition(LocationX,LocationY);
	FVector2D MousePosition(LocationX, LocationY); 
	UE_LOG(LogClass, Log, TEXT("Coords x : %i, y : %i"), LocationX, LocationY);
}

This is the controller that I’ve put to be used along with a new game mode.

I’m trying to learn to use C++, which I’m not good at :).

Thanks !

Code works fine… TEXT(“Coords x : %i, y : %i”) should be with float %f instead of i… stupid mistake :slight_smile: