Hello,
I would not bother to ask but I’m really stuck for now.
I try to make some kind of bullet penetration and was thinking about how it would be the best.
So I stumbled across bStartPenetrating and wanted to make so that a trace would start inside the wall and would end at the impact point and just fire another one with a starting point of 1unit deeper till bStartPenetrating doesn’t return true anymore to get the depth of the wall.
But bStartPenetrating ALWAYS returns true for me.
Help me please
void ABullet_762::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
FCollisionQueryParams TraceParams(FName(TEXT("ShootTrace")), true, this);
TraceParams.bTraceComplex = true;
TraceParams.bTraceAsyncScene = true;
TraceParams.bReturnPhysicalMaterial = true;
TraceParams.bFindInitialOverlaps = true;
FHitResult HitData(ForceInit);
float distance = 1.f;
GetWorld()->LineTraceSingle(HitData, Hit.ImpactPoint + (GetActorRotation().Vector() * 1.1f), Hit.ImpactPoint, ECC_WorldDynamic, TraceParams);
if (!HitData.bStartPenetrating)
{
DrawDebugPoint(GetWorld(), HitData.TraceStart, 8.f, FColor::Red, false, 10.f);
DrawDebugPoint(GetWorld(), HitData.TraceEnd, 8.f, FColor::Green, false, 10.f);
GEngine->AddOnScreenDebugMessage(-1, 2, FColor::Green, "NOPE1");
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 2, FColor::Green, "YAW!");
}
while (HitData.bStartPenetrating && distance < 2000.f)
{
distance++;
GetWorld()->LineTraceSingle(HitData, Hit.ImpactPoint + (GetActorRotation().Vector() * distance), Hit.ImpactPoint, ECC_Pawn, TraceParams);
GEngine->AddOnScreenDebugMessage(-1, 2, FColor::Green, FString::SanitizeFloat(distance));
}
}
Edit: I already tried ECC_Pawn and ECC_StaticWorld