KlintoE
(KlintoE)
July 17, 2023, 3:12pm
1
void AGun::PullTrigger()
{
UGameplayStatics::SpawnEmitterAttached(MuzzleFlash, Mesh, TEXT(“MuzzleFlashSocket”));
APawn* OwnerPawn = Cast<APawn>(GetOwner());
if(!OwnerPawn) return;
AController* OwnerController = OwnerPawn->GetController();
if(!OwnerController) return;
FRotator Rotation;
FVector Location;
OwnerController->GetPlayerViewPoint( Location, Rotation);
FVector End = Location + Rotation.Vector() * MaxRange;
FHitResult Hit;
bool bSuccess = GetWorld()->LineTraceSingleByChannel(Hit, Location, End, ECC_GameTraceChannel1);
if(bSuccess)
{
DrawDebugPoint(GetWorld(), Hit.Location, 20, FColor::Red, true);
}
}
I try to shoot bullets out of a gun from the camera point of view. But for some reason the bullets collide with the character as can be seen in the image. I’m new to unreal and a bit confused why it doesn’t go through. I made a trace channel called bulled and ticked of different boxes that should make it pass through the character.
pezzott1
(pezzott1)
July 17, 2023, 3:54pm
2
Try this:
FCollisionQueryParams QueryParams;
QueryParams.AddIgnoredActor(this);
bool bSuccess = GetWorld()->LineTraceSingleByChannel(Hit, Location, End, ECC_GameTraceChannel1, QueryParams);
KlintoE
(KlintoE)
July 17, 2023, 4:01pm
3
I’m still experiencing the same problem. It’s like there is something it collides with.
pezzott1
(pezzott1)
July 17, 2023, 4:02pm
4
KlintoE
(KlintoE)
July 17, 2023, 4:14pm
5
Yes, I’m following a older one, as they made games I was more interested in.
pezzott1
(pezzott1)
July 17, 2023, 4:28pm
6
Try same as above but use the owner QueryParams.AddIgnoredActor(OwnerPawn);
since the trace is from the weapon actor passing this
would just have the gun ignored.
KlintoE
(KlintoE)
July 17, 2023, 5:08pm
7
That fixed the problem. Is it one of the changes in unreal 5 or just me? Thanks for the help
pezzott1
(pezzott1)
July 17, 2023, 5:15pm
8
No. I’m sure the same issue persists in the lecture, it’s just that their camera is too far for it to happen.
1 Like
system
(system)
Closed
August 16, 2023, 5:16pm
9
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.