Beispiel #1
0
FHitResult ASWeapon::WeaponTrace(const FVector & inTraceFrom, const FVector & inTraceTo) const
{
	FCollisionQueryParams traceParams(TEXT("WeaponTrace"), true, Instigator);
	traceParams.bTraceAsyncScene = true;
	traceParams.bReturnPhysicalMaterial = true;

	FHitResult hit(ForceInit);
	GetWorld()->LineTraceSingleByChannel(hit, inTraceFrom, inTraceTo, COLLISION_WEAPON, traceParams);
	return hit;
}
Beispiel #2
0
bool ASkill::SphereTrace(AActor* actorToIgnore, const FVector& start, const FVector& end, const float radius, TArray<FHitResult>& hitOut, ECollisionChannel traceChannel /* = ECC_Pawn */)
{
    FCollisionQueryParams traceParams(FName(TEXT("Sphere Trace")), true, actorToIgnore);
    traceParams.bTraceComplex = true;
    traceParams.bReturnPhysicalMaterial = false;

    traceParams.AddIgnoredActor(actorToIgnore);

    TObjectIterator<APlayerController> pc;
    if (!pc)
        return false;

    DrawDebugSphere(pc->GetWorld(), start, radius, 8, FColor::Red, true);

    return pc->GetWorld()->SweepMultiByChannel(hitOut, start, end, FQuat(), traceChannel, FCollisionShape::MakeSphere(radius), traceParams);
}