I’ve followed Sam’s instructions exactly in the LineTracingByChannel lecture, and at the end of the lecture I’ve gotten this strange problem:
This is the PullTrigger method’s code:
void AGun::PullTrigger()
{
UGameplayStatics::SpawnEmitterAttached(MuzzleFlash, Mesh, TEXT("MuzzleFlashSocket"));
APawn* OwnerPawn = Cast<APawn>(GetOwner());
if (OwnerPawn == nullptr) return;
AController* OwnerController = OwnerPawn->GetController();
if (OwnerController == nullptr) return;
FVector Location;
FRotator Rotation;
OwnerController->GetPlayerViewPoint(Location, Rotation);
FVector End = Location + Rotation.Vector() * MaxRange;
//TODO Linetrace
FHitResult Hit;
bool bSuccess = GetWorld()->LineTraceSingleByChannel(Hit, Location, End, ECollisionChannel::ECC_GameTraceChannel1);
if (bSuccess)
{
DrawDebugPoint(GetWorld(), Hit.Location, 20, FColor::Red, true);
}
}
MaxRange is set to 1000 too, so I don’t know why it’s not working
I really need someone to help solve this problem so I can continue the section, any help given would be appreciated.