Line Trace to pass through 'self'

I am trying to work out how to get LineTraceSingleByChannel to pass throguh the capsule collider of my player.

I have the following code

FCollisionQueryParams CollisionParam;
CollisionParam.AddIgnoredActor(mainCharacter);
boll bIsHit = GetWorld()->LineTraceSingleByChannel(Hit, startLoc, endLoc, ECC_GameTraceChannel2, CollisionParam);

ECC_GameTraceChannel2 is a custom Trace Channel that I set up which is set to ‘Block’. In my mainCharacter BP, I have set ‘Bullet’ to Ignore.

But with all of this, the Line Trace still hits the capsule collider and I was wondering is there a way for the line trace to pass through and not hit?

Any ideas?

You should select your character capsule in character BP and ignore for your ECC_GameTraceChannel2 (Bullet).

And if you are already inside of your character cpp better to use this pointer

FCollisionQueryParams queryParams;
queryParams.AddIgnoredActor(this);

ECC_GameTraceChannel2 is a custom Trace Channel that I set up which is set to ‘Block’. In my mainCharacter BP, I have set ‘Bullet’ to Ignore.

I have done this, but it still hits the capsule for some reason. In the Project Settings under Collision, Bullet is set to Block. And the CapsuleCollider (under the collision presets), Bullet has been set to ‘Ignore’.

can you get the list of actors that your trace is hitting by and uelog name, lets be sure if its hitting capsule component.

AActor* hitActor = traceHit.GetActor();

Meanwhile I will post all of my code for you to make proper line trace:
FVector eyesLocation;
FRotator eyesRotation;

GetController()->GetPlayerViewPoint(eyesLocation,eyesRotation);

auto traceStart = eyesLocation;
auto traceEnd = (eyesRotation.Vector() * InteractionCheckDistance) + traceStart;

FHitResult traceHit;

FCollisionQueryParams queryParams;
queryParams.AddIgnoredActor(this);

I’m not sure if this will make a difference, but I believe my line trace is done in another class (my weapons class). So I’ve done

AMainCharacter* mainCharacter;
FCollisionQueryParams CollisionParam;
CollisionParam.AddIgnoredActor(mainCharacter);
bool bIsHit = GetWorld()->LineTraceSingleByChannel(Hit, startLoc, endLoc, ECC_GameTraceChannel2, CollisionParam);

Or something along them lines.

can you also ignore your weapon too by adding
CollisionParam.AddIgnoredActor(this);

Perfect, I’ll try this later on once I’m done with work and I’ll update my findings.

I have tried your solution above and still not working. The Line Trace is hitting BP_MainCharacter though.

definetely your trace start starts from wrong place, can you try to put starting position little front of weapon, or can you also make skeletal mesh of character ignore.