For example I click on a block and it will run a function
How can I do that on c++ Btw I am new at this
To click on an actor you can use the GetHusResultUnderCursor() function inside the player controller
AActor* AAnswerhubProject::GetActorFromMouse()
{
//Get a reference to the player controller
APlayerController* pc = GetWorld()->GetFirstPlayerController();
FHitResult hit;
//Attempt to hit an object underneath the mouse cursor with the Trace Collision Channel.
pc->GetHitResultUnderCursor(ECC_GameTraceChannel1, true, hit);
return hit.GetActor();
}
Once you get the clicked actor you can call your function.
Usage example:
AYourActorClass * clickedActor = Cast<AYourActorClass>(GetActorFromCursor());
if(IsValid(clickedActor))
{
clickedActor->YourFunction();
}
That should do the trick.
Good luck.
Alex