Download

Delay in Character::Tick after pressing Play multiple times

In my Character class I am performing a ray cast in Tick.


void MyCharacterClass::Tick(float DeltaTime)
{
    const FName TraceTag("MyTraceTag");
    GetWorld()->DebugDrawTraceTag = TraceTag;

    FCollisionQueryParams TraceParams = FCollisionQueryParams(FName(TEXT("InteractTrace")), true, this);
    TraceParams.bTraceComplex = false;
    TraceParams.bReturnPhysicalMaterial = false;
    TraceParams.TraceTag = TraceTag;

    FVector Start = cameraManager->GetCameraLocation(); //this->GetActorLocation();
    FVector End = Start + (cameraManager->GetActorForwardVector() * 600);
    GetWorld()->LineTraceSingleByChannel(this->InteractResult, Start, End, ECC_Pawn, TraceParams);

If we load up the Unreal Engine and press play, you can see the line trace debugging right away.

If you stop the game, and press play again, there is a delay of roughly 30 seconds before Tick is called

How can I prevent the delay for Tick?

Thanks,
Marty