void ABelovedPlayerController::LineTrace() { // get camera position and rotation this->GetPlayerViewPoint(this->cameraPos, this->cameraRot); // set up information for the linetrace const FVector StartPosTrace = cameraPos; const FVector EndPosTrace = StartPosTrace + (cameraRot.Vector() * traceLength); // start + direction * lenght // perform linetracing to get hit information FHitResult hitResult(ForceInit); GetWorld()->LineTraceSingle(hitResult, StartPosTrace, EndPosTrace, ECC_Camera, this->traceParams); // cast of the object in hitResult to an IInteractable and store it, if cast is successful ABelovedPictureFrame* const pEOObject = Cast(hitResult.GetActor()); if (pEOObject) { pInteractObject = pEOObject; GEngine->AddOnScreenDebugMessage(0, 2, FColor::Green, "Interactable Object Found!"); } else pInteractObject = NULL; }