void APlayer_character::Interact()
{
//Linetrace Log
UE_LOG(LogTemp, Display, TEXT(“”));
//Linetrace vectors
FVector Start = Camera->GetComponentLocation();
FVector End = Start + Camera->GetComponentRotation().Vector() * 300.0f;
//Linetrace Hit
FHitResult HitResult;
FCollisionQueryParams Params;
Params.AddIgnoredActor(this);
//Linetrace visibility
DrawDebugLine(GetWorld(), Start, End, FColor::Red, false, 2.0f);
//Linetrace message
if (GetWorld()->LineTraceSingleByChannel(HitResult, Start, End, ECollisionChannel::ECC_WorldStatic, Params))
{
UE_LOG(LogTemp, Display, TEXT("HIT ACTOR"));
if (HitResult.GetActor())
{
UE_LOG(LogTemp, Warning, TEXT("Hit Actor: %s"), *HitResult.GetActor()->GetName());
}
}
ADoor1* Door = Cast<ADoor1>(HitResult.GetActor());
if (Door)
{
Door->OnInteract();
}
}