Hello! I am trying to learn how to use mouse events through creating a ABaseUnit class that shall do things when I hover and click on it, but I can’t seem to atleast print a message.
Here are important parts of the code
void ABaseUnit::BeginPlay()
{
Super::BeginPlay();
FScriptDelegate ScriptDelegate;
FName FunctionToBind = FName(TEXT(“ABaseUnit::OnClick”));
ScriptDelegate.BindUFunction(this, FunctionToBind);
UCapsuleComponent* CapsuleComponent = GetComponentByClass();
CapsuleComponent->OnClicked.Add(ScriptDelegate);
CapsuleComponent->OnBeginCursorOver.Add(ScriptDelegate);
}
void ABaseUnit::OnClick(UPrimitiveComponent* TouchedComponent) {
UE_LOG(LogTemp, Warning, TEXT(“delegate!!!”));
}
Things that I’ve done but don’t seem to help are: setting the bEnableMouseOverEvents to true (from the player controller), and this is the BP class of ABaseUnit :
Thank you very much!