I’ve been struggling with this for days now.
I need a custom cursor on-screen at all times. I already have the cursor coordinates, but I don’t know how to get the UMG Widget objects and change its properties.
I have a UMG Widget blueprint with an Image object. I want to set the image position and texture within a C++ class.
Also which is the best class to use for main menus and cursors? Should I use a HUD class? I’m currently experimenting inside the PlayerController class.
MyPlayerController.h
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "MyPlayerController.generated.h"
/**
* Used for HUD controls, Main Menu, Inventory.
*/
UCLASS()
class CPP_PROTOTYPE_API AMyPlayerController : public APlayerController
{
GENERATED_BODY()
public:
virtual void Tick(float DeltaTime) override;
public:
float MouseXPos;
float MouseYPos;
};
MyPlayerController.cpp
#include "MyPlayerController.h"
#include "Kismet/GameplayStatics.h" // temp
void AMyPlayerController::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
GetMousePosition(MouseXPos, MouseYPos);
UE_LOG(LogTemp, Warning, TEXT("Mouse Location: %f, %f"),
MouseXPos, MouseYPos);
}