I have this code:
// Detects Click Events | |
---|---|
LeverMesh->OnClicked.AddDynamic(this, &ALever::OnLeverPulled); |
And I have this code in my character:
void AMicheal::Click(const FInputActionValue& Value)
{
const bool ClickValue = Value.Get();
FVector Location
FVector Direction;
Cast<APlayerController>(GetController())->DeprojectMousePositionToWorld(Location, Direction);
FHitResult HitResult;
Reach = Location + Direction * 1000;
const bool HitButton = GetWorld()->LineTraceSingleByChannel(HitResult, Location, Reach, ECC_GameTraceChannel1);
if (HitButton)
{
UE_LOG(LogTemp, Log, TEXT("Hit Actor: %s"), *HitResult.GetActor()->GetName());
}
}
The LineTrace IS detecting the Lever, but its not calling the OnClicked Function. Ive Tried moving it to BeginPlay and the COnstructor but nothing seems to be working. Any Ideas?