LineTraceSingle not work if I change window

Hi everyone !

I’m trying manage the collisions in a pawn by LineTraceSingle. My pawn is always falling untiI it collides with a mesh. I calculate the collision with this code:

FVector StartTrace = m_lastPosition; // pawn's position in last frame.
const FVector EndTraceDown = GetActorLocation() - GetActorUpVector() * m_capsuleHeight; 

 bool collisionDown = GetWorld()->LineTraceSingle(OutTraceResultDown, StartTrace, EndTraceDown, COLLISION_PLAYER, TraceParams));

  SetActorLocation(HitLocation - GetActorUpVector() * m_capsuleHeight);

This code usually works fine, but when I change window while the viewport is playing, the pawns doesnt collide until I open again the viewport.

I dont understand what it happen. Any ideas?

I have so much code to paste, so I have simplified it , sorry .

Sorry, one line is wrong. It would be:

       SetActorLocation(HitLocation - GetActorUpVector() * -m_capsuleHeight);

I’ve already solved, but the problem was another LineTrace that fails when viewport is running in background.