I’m a bit frustrated trying to figure this out, so maybe someone here can help.
I’m working on my sidescroller character. I want to shoot a trace from it 100 x in front of it.
If I just call the trace, it will return itself as the hit actor.
if I try to use AddIgnoredActor(this) or any variant that ignores itself, it crashes in the editor when the line of code runs. Any ideas as to why this is happening?
Here is the sample code:
const FRotator Rotation = Mesh->GetComponentRotation();
FHitResult Hit;
FCollisionQueryParams QueryParams;
QueryParams.bTraceComplex = false;
QueryParams.bTraceAsyncScene = true;
QueryParams.bReturnPhysicalMaterial = false;
QueryParams.AddIgnoredActor(Controller->GetPawn()); //There is no crash if this line is not here.
GetWorld()->LineTraceSingle(Hit, GetActorLocation(), FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y) * 100, ECollisionChannel::ECC_WorldStatic, QueryParams);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, Hit.Actor->GetName());
if (Hit.GetActor() && Hit.GetActor()->ActorHasTag("Wall"))
{
CharacterMovement->Velocity.Z = CharacterMovement->JumpZVelocity;
return false;
}
try put the trace in a custom event that fires off away from tick execution line.
I don’t know how this means in C++, but in blueprint, if your line trace hits nothing while on OnTick event execution line, it will hang the controls(except custom action buttons since they fire off tick line).
I tried with the constructor, removing QueryParams.AddIgnoredActor(this) and vice-versa.
The log doesn’t seem to be providing much info, and the crash reporter itself crashes. (“The procedure entry point SetCheckUserInterruptShared could not be located in the dynamic link library. C:\WINDOWS\SYSTEM32\dbgeng.dll”)
is where it crashes (I added some UE_LOGs to test). I’m going to guess it’s a null reference for the Hit.Actor, which would make sense. Does UE4 usually report that type of error, though?