Hi guys,
I am performing a line trace multi by channel on the visibility channel, with the code below, but the AddIgnoredActor line doesn’t seem to work - my character is still getting hit by its own shots.
Code:
bool Afpscharacter::MultiRaycastInCameraDirection(TArray<FHitResult>& ResultOutHit, float RaycastRange, ECollisionChannel CollisionChannel)
{
//Start coordinates are in FPS camera
FVector Start = FPSCameraComponent->GetComponentLocation();
//Gets direction player is looking at
FVector ForwardVector = FPSCameraComponent->GetForwardVector();
//End coordinate is range away from start
FVector End = Start + (ForwardVector * RaycastRange);
FCollisionQueryParams CollisionParams;
//Ignore ourselves
CollisionParams.AddIgnoredActor(GetOwner());
CollisionParams.bReturnPhysicalMaterial = true;
//Performs raycast
bool result = GetWorld()->LineTraceMultiByChannel(ResultOutHit, Start, End, CollisionChannel, CollisionParams);
return result;
}
Log showing that I am hitting myself with my shots (as well as the enemy, labelled BP_Afpscharacter_1 or something, and I am BP_afpscharacter_0. I am also hitting a blocking cube.
[2022.08.26-18.09.07:168][345]LogTemp: Warning: Name = BP_Myfpscharacter_C_0
[2022.08.26-18.09.07:168][345]LogTemp: Warning: Name = BP_Myfpscharacter_C_1
[2022.08.26-18.09.07:168][345]LogTemp: Warning: Name = Cube_2