OnBeginCursorOver in C++

Is there someone I could talk to about getting OnBeginCursorOver to work in my Prototype? I recently learned C++, so I’m fairly new with the language, and I’m still trying to break down UE4’s API. I’m trying to implement OnBeginCursorOver on some of my actors. I have a player controller setup with MouseOverEvents enabled. The actors that I’m trying to interact with are customer actors that I’m spawning, so perhaps I could be missing something important when I build them.

Here’s my code below where I’m calling OnBeginCursorOver, again, kinda new to C++ and the UE4 API, so excuse my crappy prototype code,

#pragma once

#include “CoreMinimal.h”
#include “GameFramework/Actor.h”
#include “InteractiveInterface.h”
#include “GridTile.generated.h”

UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class AI_PROTOTYPE02_API AGridTile : public AActor, public IInteractiveInterface

// Sets default values for this actor’s properties

// Called when the game starts or when spawned
virtual void BeginPlay() override;
UStaticMeshComponent* BoxVisual;
UMaterialInterface* material;
UMaterialInstanceDynamic* DynamicMaterial;


// Called every frame
virtual void Tick(float DeltaTime) override;
void SetColor(FLinearColor color);

**void BeginCursorOver(AActor* Actor);**



#include “UObject/ConstructorHelpers.h”
#include “Components/BoxComponent.h”
#include “GridTile.h”

// Sets default values
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;

RootComponent = BoxVisual;
BoxVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation"));
static ConstructorHelpers::FObjectFinder<UStaticMesh> BoxVisualAsset(TEXT("StaticMesh'/Game/Textures/ST_Box_Brush_StaticMesh.ST_Box_Brush_StaticMesh'"));
if (BoxVisualAsset.Succeeded())


// Called when the game starts or when spawned
void AGridTile::BeginPlay()

material = BoxVisual->GetMaterial(0);
DynamicMaterial = UMaterialInstanceDynamic::Create(material, this);
BoxVisual->SetMaterial(0, DynamicMaterial);
**this->OnBeginCursorOver.AddDynamic(this, &AGridTile::BeginCursorOver);**


// Called every frame
void AGridTile::Tick(float DeltaTime)


void AGridTile::SetColor(FLinearColor color)
DynamicMaterial->SetVectorParameterValue(TEXT(“ColorOfTile”), color);

void AGridTile::BeginCursorOver(AActor Actor)*
** GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Green, “Step 2”);**


What is the question?

Afaik BeginCursorOver should be a UFUNCTION to be able to bind it properly.

1 Like

So I messed around with some of the construction settings for my actor and I added UFunction to that function and that resolved the issue. Again, noob mistake, but I’m learning. Thanks so much, I really needed this, was really burnt out! Thanks again!

I’m sure I’ve overlooked it somewhere obvious, but why do I need to turn that into a UFUNCTION? Just want to know for future reference. Thanks again!