If the bullet is fast and the polygon small then the bullet could perhaps pass 2 lines of the same polygon within 1 tick: the bullet enters and leaves the polygon. In this case you get 2 results from LinesIntersect within that loop. But the first result alters EM.Entities[].Pos and replaces it with Inter. So the following result works with the wrong position. This could be the problem.Code:// COLLISION DETECTION for I := 0 to EM.Entities.Count - 1 do for J := Low(A.Polygon) to High(A.Polygon) do if LinesIntersect(A.Polygon[J].x1, A.Polygon[J].y1, A.Polygon[J].x2, A.Polygon[J].y2, EM.Entities[I].Pos.X, EM.Entities[I].Pos.Y, EM.Entities[I].Pos.X + EM.Entities[I].xSpeed, EM.Entities[I].Pos.Y + EM.Entities[I].ySpeed, Inter) then begin EM.Entities[I].Target := Inter; EM.Entities[I].Pos := Inter; end;
Bookmarks